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
@private
# 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
@private
# 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
@private
# 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
@private
# 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
@private
# 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
@private
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 239 def _templatesandboxprefix(value) merge(templatesandboxprefix: value.to_s, replace: false) end
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
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
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
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
Use disablelimitreport instead.
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 130 def disablepp() merge(disablepp: 'true') end
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
Omit table of contents in output.
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 179 def disabletoc() merge(disabletoc: 'true') end
Includes language links supplied by extensions (for use with prop=langlinks).
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 107 def effectivelanglinks() merge(effectivelanglinks: 'true') end
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
Apply mobile main page transformations.
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 226 def mainpage() merge(mainpage: 'true') end
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
Disable images in mobile output.
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 219 def noimages() merge(noimages: 'true') end
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
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
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
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
Parse
in preview mode.
@return [self]
# File lib/mediawiktory/wikipedia/actions/parse.rb, line 165 def preview() merge(preview: 'true') end
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
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
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
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
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
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 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
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
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
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
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
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 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 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