Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a40b4c6eee7b5a3a

Jump to content

Module:Sandbox/Squc/Roman/doc

From Wikipedia, the free encyclopedia

This module converts Roman numerals to decimal form, and rejects invalid ones. It can be used normally, or through another module. This is still under construction, check back in a few days!

This module is intended to run through a template, which is still under construction.

To convert Roman numerals to decimal form, use {{#invoke:Sandbox/Squc/Roman/doc|todecimal|MMXIII}}, which outputs 2013. If the Roman numeral is invalid, it will throw an error. If JavaScript is enabled, you can click the Script error link, and the first sentence should show the cause of the error. The final value will still be given in brackets after the error messages.

To force no errors, use {{#invoke:Sandbox/Squc/Roman/doc|todecimal|MMXIII}}.

To output errors directly into the text, use {{#invoke:Sandbox/Squc/Roman/doc|todecimal|MMXIII}}.

To use this through another module, use something like this:

local roman = require( "Module:Sandbox/Squc/Roman" )

local romannum = "MMXIII"
local value = roman.todecimald( romannum )


Error demonstration
functionNo errorsWarningsInvalidErrors
ExampleMMXIIIXXXXXXCCABC
todecimal201350 Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5190 Roman numeral usage errors: Repeat after subtraction - XCC - roman numeral 3, char 3100 Syntax errors: Unknown character "A" found - char 1; Unknown character "B" found - char 2
todecimal|mode=1201350190100
todecimal|mode=2|disp=Decimal ...Decimal number: 2013, Errors , Time 0.01592Decimal number: 50, Errors Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5, Time 0.01632Decimal number: 190, Errors Roman numeral usage errors: Repeat after subtraction - XCC - roman numeral 3, char 3, Time 0.01672Decimal number: 100, Errors Syntax errors: Unknown character "A" found - char 1; Unknown character "B" found - char 2, Time 0.0171
todecimaldIntended for use only from other modules. See below for more details.

Errors will be combined, e.g. "XXXXXXCC" gives:

Decimal number: 140, Errors Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5; More than four X in a row, suggestion: L? - roman numeral 6, char 6; Number of X before X must be at most two - roman numeral 7, char 7; Repeat after subtraction - XCC - roman numeral 8, char 8, Time 0.01754

or with mode=2|disp=0 (default):

[num]140 [err]Roman numeral usage errors: More than four X in a row, suggestion: L? - roman numeral 5, char 5; More than four X in a row, suggestion: L? - roman numeral 6, char 6; Number of X before X must be at most two - roman numeral 7, char 7; Repeat after subtraction - XCC - roman numeral 8, char 8 [time]0.01796

todecimald

The function todecimald (direct) is only intended for use in other modules. The output will be in the form (comma-separated list): Decimal, Error message, Time taken

The decimal will be a number, it will be the converted number if there are no errors or if it is a warning (it is invalid but still can be converted), it will be -1 if there is an error (cannot be converted). The error message is a string and will always exist, it will be "" if no error is found.