{
    "content": [
        {
            "type": "text",
            "text": "# Text::WikiFormat (perldoc)\n\n## NAME\n\nText::WikiFormat - module for translating Wiki formatted text into other formats\n\n## SYNOPSIS\n\nuse Text::WikiFormat;\nmy $html = Text::WikiFormat::format($raw);\n\n## DESCRIPTION\n\nThe original Wiki web site had a very simple interface to edit and to add pages. Its formatting\nrules are simple and easy to use. They are also easy to translate into other, more complicated\nmarkup languages with this module. It creates HTML by default, but can produce valid POD,\nDocBook, XML, or any other format imaginable.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION** (1 subsections)\n- **EXPORT**\n- **GORY DETAILS** (1 subsections)\n- **AUTHOR**\n- **BUGS**\n- **TODO**\n- **OTHER MODULES**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Text::WikiFormat",
        "section": "",
        "mode": "perldoc",
        "summary": "Text::WikiFormat - module for translating Wiki formatted text into other formats",
        "synopsis": "use Text::WikiFormat;\nmy $html = Text::WikiFormat::format($raw);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 59,
                "subsections": [
                    {
                        "name": "Wiki Format",
                        "lines": 35
                    }
                ]
            },
            {
                "name": "EXPORT",
                "lines": 37,
                "subsections": []
            },
            {
                "name": "GORY DETAILS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Tags",
                        "lines": 126
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "TODO",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "OTHER MODULES",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Text::WikiFormat - module for translating Wiki formatted text into other formats\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Text::WikiFormat;\nmy $html = Text::WikiFormat::format($raw);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The original Wiki web site had a very simple interface to edit and to add pages. Its formatting\nrules are simple and easy to use. They are also easy to translate into other, more complicated\nmarkup languages with this module. It creates HTML by default, but can produce valid POD,\nDocBook, XML, or any other format imaginable.\n\nThe most important function is \"format()\". It is not exported by default.\n\nformat()\n\"format()\" takes one required argument, the text to convert, and returns the converted text. It\nallows two optional arguments. The first is a reference to a hash of tags. Anything passed in\nhere will override the default tag behavior. The second argument is a hash reference of options.\nThey are currently:\n\n*   prefix\n\nThe prefix of any links. In HTML mode, this is the path to the Wiki. The actual linked item\nitself will be appended to the prefix. This is useful to create full URIs:\n\n{ prefix => 'http://example.com/wiki.pl?page=' }\n\n*   extended\n\nA boolean flag, false by default, to use extended linking semantics. This comes from the\nEverything Engine (http://everydevel.com/), which marks links with square brackets. An\noptional title may occur after the link target, preceded by an open pipe. These are valid\nextended links:\n\n[a valid link]\n[link|title]\n\nWhere the linking semantics of the destination format allow it, the result will display the\ntitle instead of the URI. In HTML terms, the title is the content of an \"A\" element (not the\ncontent of its \"HREF\" attribute).\n\nYou can use delimiters other than single square brackets for marking extended links by\npassing a value for \"extendedlinkdelimiters\" in the %tags hash when calling \"format\".\n\n*   implicitlinks\n\nA boolean flag, true by default, to create links from StudlyCapsStringsNote that if you\ndisable this flag, you should probably enable the \"extended\" one also, or there will be no\nway of creating links in your documents. To disable it, use the pair:\n\n{ implicitlinks => 0 }\n\n*   absolutelinks\n\nA boolean flag, false by default, which treats any links that are absolute URIs (such as\nhttp://www.cpan.org/) specially. Any prefix will not apply and the URIs aren't quoted. Use\nthis in conjunction with the \"extended\" option to detect the link.\n\nA link is any text that starts with a known schema followed by a colon and one or more\nnon-whitespace characters. This is a distinct subset of what URI recognizes as a URI, but is\na good first-order approximation. If you need to recognize more complex URIs, use the\nstandard wiki formatting explained earlier.\n\nThe recognized schemas are those defined in the \"schema\" value in the %tags hash. The\ndefaults are \"http\", \"https\", \"ftp\", \"mailto\", and \"gopher\".\n",
                "subsections": [
                    {
                        "name": "Wiki Format",
                        "content": "Wiki formatting is very simple. An item wrapped in three single quotes is strong. An item\nwrapped in two single quotes is *emphasized*. Any word with multiple CapitalLetters (e. g.,\nStudlyCaps) will become a link. Four or more hyphen characters at the start of a line create a\nhorizontal line. Newlines turn into the appropriate tags. Headers are matching equals signs\naround the header text -- the more signs, the lesser the header.\n\nLists are indented text, by one tab or four spaces by default. You may disable indentation. In\nunordered lists, where each item has its own bullet point, each item needs a leading asterisk\nand space. Ordered lists consist of items marked with combination of one or more alphanumeric\ncharacters followed by a period and an optional space. Any indented text without either marking\nis code, handled literally. You can nest lists.\n\nThe following is valid Wiki formatting, with an extended link as marked.\n\n= my interesting text =\n\nANormalLink\n[let the Sun shine|AnExtendedLink]\n\n== my interesting lists ==\n\n* unordered one\n* unordered two\n\n1. ordered one\n2. ordered two\na. nested one\nb. nested two\n\ncode one\ncode two\n\nThe first line of a normal paragraph.\nThe second line of a normal paragraph.  Whee.\n"
                    }
                ]
            },
            "EXPORT": {
                "content": "If you'd like to make your life more convenient, you can optionally import a subroutine that\nalready has default tags and options set up. This is especially handy if you use a prefix:\n\nuse Text::WikiFormat prefix => 'http://www.example.com/';\nwikiformat( 'some text' );\n\nTags are interpreted as, well, tags, except for five special keys:\n\n*   \"prefix\", interpreted as a link prefix\n\n*   \"extended\", interpreted as the extended link flag\n\n*   \"implicitlinks\", interpreted as the flag to control implicit links\n\n*   \"absolutelinks\", interpreted as the flag to control absolute links\n\n*   \"as\", interpreted as an alias for the imported function\n\nUse the \"as\" flag to control the name by which your code calls the imported functionFor example,\n\nuse Text::WikiFormat as => 'formatTextInWikiStyle';\nformatTextInWikiStyle( 'some text' );\n\nYou might choose a better name, though.\n\nThe calling semantics are effectively the same as those of the format() function. Any additional\ntags or options to the imported function will override the defaults. This code:\n\nuse Text::WikiFormat as => 'wf', extended => 0;\nwf( 'some text', {}, { extended => 1 });\n\nenables extended links, though the default is to disable them.\n\nTony Bowden <tony@kasei.com> suggested this feature, but all implementation blame rests solely\nwith me. Kate L Pugh (<kake@earth.li>) pointed out that it didn't work, with tests. It works\nnow.\n",
                "subsections": []
            },
            "GORY DETAILS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Tags",
                        "content": "There are two types of Wiki markup: line items and blocks. Blocks include lists, which are made\nup of lines and can also contain other lists.\n\nLine items\nThere are two classes of line items: simple tags, and tags that contain data. The simple tags\nare \"newline\" and \"line\". The module inserts a newline tag whenever it encounters a newline\ncharacter (\"\\n\"). It inserts a line tag whenever four or more dash characters (\"----\") occur at\nthe start of a line. No whitespace is allowed. These default to the <br> and <hr> HTML tags,\nrespectively. To override either, simply pass tags such as:\n\nmy $html = format($text, { newline => \"\\n\" });\n\nThe three line items are more complex, and require subroutine references. This category includes\nthe \"strong\" and \"emphasized\" tags as well as \"link\"s. The first argument passed to the subref\nwill be the data found in between the marks. The second argument is the $opts hash reference.\nThe default action for a strong tag is equivalent to:\n\nmy $html = format($text, { strong => sub { \"<b>$[0]</b>\" } });\n\nAs of version 0.70, you can change the regular expressions used to find strong and emphasized\ntags:\n\n%tags = (\nstrongtag     => qr/\\*(.+?)\\*/,\nemphasizedtag => qr|(?<!<)/(.+?)/|,\n);\n\n$wikitext = 'this is *strong*, /emphasized/, and */emphasized strong/*';\n$htmltext = Text::WikiFormat::format( $wikitext, \\%tags, {} );\n\nBe aware that using forward slashes to mark anything leads to the hairy regular expression --\nuse something else. This interface is experimental and may change if I find something better.\nIt's nice to be able to override those tags, though.\n\nFinally, there are \"extendedlinkdelimiters\", which allow you to use delimiters other than\nsingle square brackets for marking extended links. Pass the tags as:\n\nmy $html = format( $text, { extendedlinkdelimiters => [ '[[', ']]' ] });\n\nThis allows you to use double square brackets as UseMod supports:\n\n[[an extended link]]\n[[a titled extended link|title]]\n\nBlocks\nThere are five default block types: \"paragraph\", \"header\", \"code\", \"unordered\", and \"ordered\".\nThe parser usually finds these by indentation, either one or more tabs or four or more\nwhitespace characters. (This does not include newlines, however.) Any line that does not fall in\nany of these three categories is a \"paragraph\".\n\nCode, unordered, and ordered blocks do not *require* indentation, but the parser uses it to\ncontrol nesting in lists. Be careful. To mark a block as requiring indentation, use the\n\"indented\" tag, which contains a reference to a hash:\n\nmy $html = format($text, {\nindented    => { map { $ => 1 } qw( ordered unordered code )}\n});\n\nBlock entries in the tag hashes must contain array references. The first two items are the tags\nused at the start and end of the block. The last items contain the tags used at the start and\nend of each line. Where there needs to be more processing of individual lines, use a subref as\nthe third item. This is how the module numbers ordered lines in HTML lists:\n\nmy $html = format($text, { ordered => [ '<ol>', \"</ol>\\n\",\nsub { qq|<li value=\"$[2]\">$[0]</li>\\n| } ] });\n\nThe first argument to these subrefs is the post-processed text of the line itself. (Processing\nremoves the indentation and tokens used to mark this as a list and checks the rest of the line\nfor other line formattings.) The second argument is the indentation level. The subsequent\narguments are captured variables in the regular expression used to find this list type. The\nregexp for ordered lists is:\n\nqr/^([\\dA-Za-z]+)\\.\\s*/;\n\nThe module processes indentation first, if applicable, and stores the indentation level (the\nlength of the indentation removed). The line must contain one or more alphanumeric character\nfollowed by a single period and optional whitespace to be an ordered list item. The module saves\nthe contents of this last group, the value of the list item, and passes it to the subref as the\nthird argument.\n\nLists automatically start and end as necessary.\n\nBecause of the indentation issue, there is a specific blocks processing in a specific order. The\n\"blockorder\" tag governs this order. It contains a reference to an array of the names of the\nappropriate blocks to process. If you add a block type, be sure to add an entry for it in\n\"blockorder\":\n\nmy $html = format($text, {\nescaped       => [ '', '', '', '' ],\nblocks        => {\ninvisible => qr!^--(.*?)--$!,\n},\nblockorder    =>\n[qw( header line ordered unordered code paragraph invisible )],\n});\n\nFinding blocks\nText::WikiFormat uses regular expressions to find blocks. These are in the %tags hash under the\n\"blocks\" key. To change the regular expression to find code block items, use:\n\nmy $html     =  format($wikitext, {\nblocks   => {\ncode => qr/^:\\s+/,\n},\nindented => {\ncode => 1,\n},\n);\n\nThis will require indentation and a colon to mark code lines. A potential shortcut is to use the\n\"indent\" tag to match or to change the indentation marker.\n\nNote: if you want to mark a block type as non-indented, you cannot use an empty regex such as\n\"qr//\". Use a mostly-empty, always-true regex such as \"qr/^/\" instead.\n\nFinding Blocks in the Correct Order\nAs intrepid bug reporter Tom Hukins pointed out in CPAN RT bug #671, the order in which\nText::WikiFormat searches for blocks varies by platform and version of Perl. Because some\nblock-finding regular expressions are more specific than others, what you intend to be one type\nof block may turn into a different list type.\n\nIf you're adding new block types, be aware of this. The \"blockorder\" entry in %tags exists to\nforce Text::WikiFormat to apply its regexes from most specific to least specific. It contains an\narray reference. By default, it looks for ordered lists first, unordered lists second, and code\nreferences at the end.\n"
                    }
                ]
            },
            "AUTHOR": {
                "content": "chromatic, \"chromatic@wgz.org\", with much input from the Jellybean team (including Jonathan\nPaulett). Kate L Pugh has also provided several patches, many failing tests, and is usually the\ndriving force behind new features and releases. If you think this module is worth buying me a\nbeer, she deserves at least half of it.\n\nAlex Vandiver added a nice patch and tests for extended links.\n\nTony Bowden, Tom Hukins, and Andy H. all suggested useful features that are now implemented.\n\nSam Vilain, Chris Winters, Paul Schmidt, and Art Henry have all found and reported silly bugs.\n\nBlame me for the implementation.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "The link checker in \"formatline()\" may fail to detect existing links that do not follow HTML,\nXML, or SGML style. They may die with some SGML styles too. *Sic transit gloria mundi*.\n",
                "subsections": []
            },
            "TODO": {
                "content": "*   Find a nicer way to mark list as having unformatted lines\n\n*   Optimize \"formatline()\" to work on a list of lines\n\n*   Handle nested \"strong\" and \"emphasized\" markings better\n",
                "subsections": []
            },
            "OTHER MODULES": {
                "content": "Brian \"Ingy\" Ingerson's CGI::Kwiki has a fairly nice parser.\n\nJohn McNamara's Pod::Simple::Wiki looks like a good project.\n\nMatt Sergeant keeps threatening to write a nice SAX-throwing Wiki formatter.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright (c) 2002 - 2006, chromatic. All rights reserved. This module is distributed under the\nsame terms as Perl itself.\n",
                "subsections": []
            }
        }
    }
}