class MediaWiktory::Wikipedia::Actions::Parse

Parses content and returns parser output.

Usage:

“`ruby api.parse.title(value).perform # returns string with raw output # or api.parse.title(value).response # returns output parsed and wrapped into Response object “`

See {Base} for generic explanation of working with MediaWiki actions and {MediaWiktory::Wikipedia::Response} for working with action responses.

All action's parameters are documented as its public methods, see below.

Public Instance Methods

_contentformat(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 192
def _contentformat(value)
  defined?(super) && super || ["application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain"].include?(value.to_s) && merge(contentformat: value.to_s)
end
_contentmodel(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 205
def _contentmodel(value)
  defined?(super) && super || ["GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto"].include?(value.to_s) && merge(contentmodel: value.to_s)
end
_prop(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 86
def _prop(value)
  defined?(super) && super || ["text", "langlinks", "categories", "categorieshtml", "links", "templates", "images", "externallinks", "sections", "revid", "displaytitle", "headitems", "headhtml", "modules", "jsconfigvars", "encodedjsconfigvars", "indicators", "iwlinks", "wikitext", "properties", "limitreportdata", "limitreporthtml", "parsetree", "parsewarnings"].include?(value.to_s) && merge(prop: value.to_s, replace: false)
end
_templatesandboxcontentformat(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 281
def _templatesandboxcontentformat(value)
  defined?(super) && super || ["application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain"].include?(value.to_s) && merge(templatesandboxcontentformat: value.to_s)
end
_templatesandboxcontentmodel(value) click to toggle source

@private

Calls superclass method
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 268
def _templatesandboxcontentmodel(value)
  defined?(super) && super || ["GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto"].include?(value.to_s) && merge(templatesandboxcontentmodel: value.to_s)
end
_templatesandboxprefix(value) click to toggle source

@private

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 239
def _templatesandboxprefix(value)
  merge(templatesandboxprefix: value.to_s, replace: false)
end
contentformat(value) click to toggle source

Content serialization format used for the input text. Only valid when used with text.

@param value [String] One of “application/json”, “text/x-wiki”, “text/javascript”, “text/css”, “text/plain”. @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 187
def contentformat(value)
  _contentformat(value) or fail ArgumentError, "Unknown value for contentformat: #{value}"
end
contentmodel(value) click to toggle source

Content model of the input text. If omitted, title must be specified, and default will be the model of the specified title. Only valid when used with text.

@param value [String] One of “GadgetDefinition”, “SecurePoll”, “MassMessageListContent”, “JsonSchema”, “wikitext”, “javascript”, “json”, “css”, “text”, “Scribunto”. @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 200
def contentmodel(value)
  _contentmodel(value) or fail ArgumentError, "Unknown value for contentmodel: #{value}"
end
disableeditsection() click to toggle source

Omit edit section links from the parser output.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 144
def disableeditsection()
  merge(disableeditsection: 'true')
end
disablelimitreport() click to toggle source

Omit the limit report (“NewPP limit report”) from the parser output.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 137
def disablelimitreport()
  merge(disablelimitreport: 'true')
end
disablepp() click to toggle source

Use disablelimitreport instead.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 130
def disablepp()
  merge(disablepp: 'true')
end
disabletidy() click to toggle source

Do not run HTML cleanup (e.g. tidy) on the parser output.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 151
def disabletidy()
  merge(disabletidy: 'true')
end
disabletoc() click to toggle source

Omit table of contents in output.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 179
def disabletoc()
  merge(disabletoc: 'true')
end
generatexml() click to toggle source

Generate XML parse tree (requires content model wikitext; replaced by prop=parsetree).

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 158
def generatexml()
  merge(generatexml: 'true')
end
mainpage() click to toggle source

Apply mobile main page transformations.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 226
def mainpage()
  merge(mainpage: 'true')
end
mobileformat() click to toggle source

Return parse output in a format suitable for mobile devices.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 212
def mobileformat()
  merge(mobileformat: 'true')
end
noimages() click to toggle source

Disable images in mobile output.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 219
def noimages()
  merge(noimages: 'true')
end
oldid(value) click to toggle source

Parse the content of this revision. Overrides page and pageid.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 73
def oldid(value)
  merge(oldid: value.to_s)
end
onlypst() click to toggle source

Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with text.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 100
def onlypst()
  merge(onlypst: 'true')
end
page(value) click to toggle source

Parse the content of this page. Cannot be used together with text and title.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 50
def page(value)
  merge(page: value.to_s)
end
pageid(value) click to toggle source

Parse the content of this page. Overrides page.

@param value [Integer] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 58
def pageid(value)
  merge(pageid: value.to_s)
end
preview() click to toggle source

Parse in preview mode.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 165
def preview()
  merge(preview: 'true')
end
prop(*values) click to toggle source

Which pieces of information to get:

@param values [Array<String>] Allowed values: “text” (Gives the parsed text of the wikitext), “langlinks” (Gives the language links in the parsed wikitext), “categories” (Gives the categories in the parsed wikitext), “categorieshtml” (Gives the HTML version of the categories), “links” (Gives the internal links in the parsed wikitext), “templates” (Gives the templates in the parsed wikitext), “images” (Gives the images in the parsed wikitext), “externallinks” (Gives the external links in the parsed wikitext), “sections” (Gives the sections in the parsed wikitext), “revid” (Adds the revision ID of the parsed page), “displaytitle” (Adds the title of the parsed wikitext), “headitems” (Deprecated. Gives items to put in the <head> of the page), “headhtml” (Gives parsed <head> of the page), “modules” (Gives the ResourceLoader modules used on the page. To load, use mw.loader.using(). Either jsconfigvars or encodedjsconfigvars must be requested jointly with modules), “jsconfigvars” (Gives the JavaScript configuration variables specific to the page. To apply, use mw.config.set()), “encodedjsconfigvars” (Gives the JavaScript configuration variables specific to the page as a JSON string), “indicators” (Gives the HTML of page status indicators used on the page), “iwlinks” (Gives interwiki links in the parsed wikitext), “wikitext” (Gives the original wikitext that was parsed), “properties” (Gives various properties defined in the parsed wikitext), “limitreportdata” (Gives the limit report in a structured way. Gives no data, when disablelimitreport is set), “limitreporthtml” (Gives the HTML version of the limit report. Gives no data, when disablelimitreport is set), “parsetree” (The XML parse tree of revision content (requires content model wikitext)), “parsewarnings” (Gives the warnings that occurred while parsing content). @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 81
def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end
pst() click to toggle source

Do a pre-save transform on the input before parsing it. Only valid when used with text.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 93
def pst()
  merge(pst: 'true')
end
redirects() click to toggle source

If page or pageid is set to a redirect, resolve it.

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 65
def redirects()
  merge(redirects: 'true')
end
section(value) click to toggle source

Only parse the content of this section number.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 115
def section(value)
  merge(section: value.to_s)
end
sectionpreview() click to toggle source

Parse in section preview mode (enables preview mode too).

@return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 172
def sectionpreview()
  merge(sectionpreview: 'true')
end
sectiontitle(value) click to toggle source

New section title when section is new.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 123
def sectiontitle(value)
  merge(sectiontitle: value.to_s)
end
summary(value) click to toggle source

Summary to parse.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 42
def summary(value)
  merge(summary: value.to_s)
end
templatesandboxcontentformat(value) click to toggle source

Content format of templatesandboxtext.

@param value [String] One of “application/json”, “text/x-wiki”, “text/javascript”, “text/css”, “text/plain”. @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 276
def templatesandboxcontentformat(value)
  _templatesandboxcontentformat(value) or fail ArgumentError, "Unknown value for templatesandboxcontentformat: #{value}"
end
templatesandboxcontentmodel(value) click to toggle source

Content model of templatesandboxtext.

@param value [String] One of “GadgetDefinition”, “SecurePoll”, “MassMessageListContent”, “JsonSchema”, “wikitext”, “javascript”, “json”, “css”, “text”, “Scribunto”. @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 263
def templatesandboxcontentmodel(value)
  _templatesandboxcontentmodel(value) or fail ArgumentError, "Unknown value for templatesandboxcontentmodel: #{value}"
end
templatesandboxprefix(*values) click to toggle source

Template sandbox prefix, as with Special:TemplateSandbox.

@param values [Array<String>] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 234
def templatesandboxprefix(*values)
  values.inject(self) { |res, val| res._templatesandboxprefix(val) }
end
templatesandboxtext(value) click to toggle source

Parse the page using this page content in place of the page named by templatesandboxtitle.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 255
def templatesandboxtext(value)
  merge(templatesandboxtext: value.to_s)
end
templatesandboxtitle(value) click to toggle source

Parse the page using templatesandboxtext in place of the contents of the page named here.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 247
def templatesandboxtitle(value)
  merge(templatesandboxtitle: value.to_s)
end
text(value) click to toggle source

Text to parse. Use title or contentmodel to control the content model.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 34
def text(value)
  merge(text: value.to_s)
end
title(value) click to toggle source

Title of page the text belongs to. If omitted, contentmodel must be specified, and API will be used as the title.

@param value [String] @return [self]

# File lib/mediawiktory/wikipedia/actions/parse.rb, line 26
def title(value)
  merge(title: value.to_s)
end