{"id":13897541,"url":"https://github.com/wincent/wikitext","last_synced_at":"2025-05-08T19:52:33.254Z","repository":{"id":568524,"uuid":"199929","full_name":"wincent/wikitext","owner":"wincent","description":"🌐 Fast wikitext-to-HTML translator","archived":false,"fork":false,"pushed_at":"2024-03-28T22:16:40.000Z","size":4490,"stargazers_count":38,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-24T13:16:14.902Z","etag":null,"topics":["ruby","wiki"],"latest_commit_sha":null,"homepage":"http://wincent.github.io/wikitext/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dustin/go-humanize","license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wincent.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2009-05-13T15:56:58.000Z","updated_at":"2024-06-09T00:34:33.417Z","dependencies_parsed_at":"2024-06-09T00:44:32.747Z","dependency_job_id":null,"html_url":"https://github.com/wincent/wikitext","commit_stats":{"total_commits":783,"total_committers":4,"mean_commits":195.75,"dds":"0.025542784163473775","last_synced_commit":"1c1ef9affa4633e6c169a9c1c8e9b2aee11c3679"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Fwikitext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Fwikitext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Fwikitext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wincent%2Fwikitext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wincent","download_url":"https://codeload.github.com/wincent/wikitext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225110575,"owners_count":17422411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","wiki"],"created_at":"2024-08-06T18:03:40.617Z","updated_at":"2024-11-18T01:05:28.988Z","avatar_url":"https://github.com/wincent.png","language":"Ruby","readme":"= Wikitext\n\nThe Wikitext extension is a fast wikitext-to-HTML translator written\nin C and packaged as a Ruby extension.\n\nUsage is straightforward:\n\n    !!!plain\n    $ irb -r wikitext\n    \u003e\u003e Wikitext::Parser.new.parse(\"hello world!\")\n    =\u003e \"\u003cp\u003ehello world!\u003c/p\u003e\\n\"\n\n= Design goals\n\nI needed a wikitext-to-HTML translator for a Rails application; a number\nof design goals flowed on from this:\n\n* _fast_: Rails has a reputation for being slow, so the translator had\n  to be part of the solution, not part of the problem\n* _efficient_: again, given how much memory Rails likes to use, the\n  translator had to be very memory-efficient\n* _robust_: on a public-facing web application that had to be up for long\n  periods, the translator had to be stable (no crashes, no resource leaks)\n* _secure_: again, accepting input from untrusted sources meant that the\n  translator had to sanitize or reject unsafe input\n* \u003cem\u003eeasy to use\u003c/em\u003e: for end users, the translator should provide a\n  simple, familiar markup as close as possible to what they already know\n  from other applications (such as MediaWiki, the wiki software that\n  powers Wikipedia)\n* _forgiving_: wikitext is presentation markup, not source code, so the\n  translator should do a reasonable job of formatting even the most\n  invalid markup rather than giving up\n* _informative_: when provided invalid markup the translator should\n  fail gracefully and emit HTML that provides useful visual feedback\n  about where the errors are in the input\n* \u003cem\u003emultilingual-friendly\u003c/em\u003e: the translator should handle input beyond\n  printable ASCII in a compatible fashion\n* _attractive_: the emitted HTML source should be consistent and attractive\n* \u003cem\u003evalid output\u003c/em\u003e: regardless of the input, the translator should\n  always produce valid HTML5 output\n* \u003cem\u003ewell-tested\u003c/em\u003e: the translator should have a comprehensive test\n  suite to ensure that its behaviour is not only correct but also stable\n  over time\n* \u003cem\u003ecross-platform\u003c/em\u003e: should work identically on Mac OS X, Linux\n  (explicitly tested platforms) and perhaps others as well\n\nSome notable things that were _not_ design goals:\n\n* implement _all_ of the MediaWiki syntax (tables etc)\n\n= Markup\n\nThe markup is very close to that used by MediaWiki, the most popular wiki\nsoftware and the one that powers Wikipedia.\n\n== Headings\n\n    !!!wikitext\n    = Heading 1 =\n    == Heading 2 ==\n    === Heading 3 ===\n    ==== Heading 4 ====\n    ===== Heading 5 =====\n    ====== Heading 6 ======\n\nAre marked up as:\n\n    !!!html\n    \u003ch1\u003eHeading 1\u003c/h1\u003e\n    \u003ch2\u003eHeading 2\u003c/h2\u003e\n    \u003ch3\u003eHeading 3\u003c/h3\u003e\n    \u003ch4\u003eHeading 4\u003c/h4\u003e\n    \u003ch5\u003eHeading 5\u003c/h5\u003e\n    \u003ch6\u003eHeading 6\u003c/h6\u003e\n\n== Paragraphs\n\nConsecutive linebreaks are converted into paragraph breaks.\n\n    !!!wikitext\n    This is one paragraph.\n    Another line.\n    \n    And this is another.\n\nWould be marked up as:\n\n    !!!html\n    \u003cp\u003eThis is one paragraph. Another line.\u003c/p\u003e\n    \u003cp\u003eAnd this is another.\u003c/p\u003e\n\n== Emphasis, Strong\n\nEmphasis is marked up as follows:\n\n    !!!wikitext\n    ''emphasized''\n\nWhich gets translated into:\n\n    !!!html\n    \u003cem\u003eemphasized\u003c/em\u003e\n\nStrong is marked up like this:\n\n    !!!wikitext\n    '''strong text'''\n\nAnd transformed into:\n\n    !!!html\n    \u003cstrong\u003estrong text\u003c/strong\u003e\n\nYou can nest spans inside one another, provided you don't try to produce\ninvalid HTML (for example, nesting strong inside strong). Here is a valid\nexample:\n\n    !!!wikitext\n    '''''foo'' bar''' baz\n\nThis would become:\n\n    !!!html\n    \u003cstrong\u003e\u003cem\u003efoo\u003c/em\u003e bar\u003c/strong\u003e baz\n\nNote that the translator emits HTML on the fly, so when it sees the\nfirst run of five apostrophes it has no way of knowing what will come\nafterwards and so doesn't know whether you mean to say \"strong em\" or\n\"em strong\"; it therefore always assumes \"strong em\". If you wish to\nforce the alternative interpretation you can do one of the following:\n\n    !!!wikitext\n    '' '''foo''' bar'' baz (ie. use whitespace)\n    ''\u003cnowiki\u003e\u003c/nowiki\u003e'''foo''' bar'' baz (ie. insert an empty nowiki span)\n    \u003cem\u003e\u003cstrong\u003efoo\u003c/strong\u003e bar\u003c/em\u003e baz (ie. use explicit HTML tags instead)\n    \u003cem\u003e'''foo''' bar\u003c/em\u003e baz (ie. use explicit HTML tags instead)\n\nNote that to avoid ambiguity, the translator will not let you intermix\nthe shorthand style with the literal HTML tag style.\n\n    !!!wikitext\n    \u003cem\u003efoo'' (ie. intermixed, invalid)\n\n== Teletype\n\nThe translator recognizes both standard HTML +tt+ tags and the\nbacktick (`) as a shorthand. These two are equivalent:\n\n    !!!wikitext\n    \u003ctt\u003efixed\u003c/tt\u003e\n    `fixed`\n\nAs of version 2.0, this markup is actually translated to +code+ tags\nin the output because the +tt+ tag was removed from the HTML5 standard.\n\nIf you need to insert a literal backtick in your text you use a +nowiki+\nspan:\n\n    !!!wikitext\n    here follows a literal \u003cnowiki\u003e`\u003c/nowiki\u003e backtick\n\nTo avoid ambiguity, the translator will not let you intermix the two\nstyles.\n\n== +nowiki+ spans\n\nAlready mentioned above, you can use +nowiki+ tags to temporarily disable\nwikitext markup. As soon as the translator sees the opening +nowiki+ tag\nit starts emitting a literal copy of everything it sees up until the\nclosing +nowiki+ tag:\n\n    !!!wikitext\n    Hello \u003cnowiki\u003e''world''\u003c/nowiki\u003e\n\nWould be emitted as:\n\n    !!!html\n    Hello ''world''\n\n== Blockquotes\n\n    !!!wikitext\n    \u003e Hello world!\n    \u003e Bye for now.\n\nWould be emitted as:\n\n    !!!html\n    \u003cblockquote\u003e\u003cp\u003eHello world! Bye for now.\u003c/p\u003e\u003c/blockquote\u003e\n\nYou can nest blockquotes or any other kind of block or span inside\nblockquotes. For example:\n\n    !!!wikitext\n    \u003e first quote\n    \u003e\u003e quote inside a quote\n\n== Preformatted text\n\nAny line indented with whitespace will be interpreted as part of a +pre+\nblock. Wikitext markup inside +pre+ blocks has no special meaning. For\nexample, consider the following block indented by a single space:\n\n    !!!wikitext\n     // source code listing\n     void foo(void)\n     {\n         x++;\n     }\n\nWould be translated into:\n\n    !!!html\n    \u003cpre\u003e// source code listing\n    void foo(void)\n    {\n        x++;\n    }\u003c/pre\u003e\n\n+pre+ blocks may be nested inside +blockquote+ blocks.\n\n== Internal links\n\n    !!!wikitext\n    [[article title]]\n\nWould become:\n\n    !!!html\n    \u003ca href=\"/wiki/article_title\"\u003earticle title\u003c/a\u003e\n\nAnd:\n\n    !!!wikitext\n    [[title|link text]]\n\nWould become:\n\n    !!!html\n    \u003ca href=\"/wiki/article\"\u003elink text\u003c/a\u003e\n\nSee the Wikitext::Parser attributes documentation for how you can override\nthe default link prefix (\u003cem\u003e/wiki/\u003c/em\u003e as shown in the example), and how\n\"red links\" can be implemented by applying custom CSS depending on the\nlink target (this can be used to make links to non-existent pages appear\nin a different color).\n\n== Alternative blockquote and preformatted block syntax\n\nFor +blockquote+ and +pre+ blocks that go on for many lines it may be\nmore convenient to use the alternative syntax which uses standard\nHTML tags rather than special prefixes at the beginning of each line.\n\n    !!!wikitext\n    \u003cblockquote\u003eThis is\n    a blockquote!\u003c/blockquote\u003e\n    \n    \u003cpre\u003eAnd this is\n    preformatted text\u003c/pre\u003e\n\n+blockquote+ and +pre+ blocks may nest inside other +blockquote+\nblocks.\n\nNote that to avoid ambiguity, the translator will not let you intermix\nthe two styles (HTML markup and wikitext markup).\n\n+pre+ blocks may also contain a custom +lang+ attribute for the purposes\nof marking up a block for syntax-highlighting (note that the highlighting\nitself would be provided by JavaScript in the browser and is not actually\npart of the Wikitext extension). For example:\n\n    !!!wikitext\n    \u003cpre lang=\"ruby\"\u003eputs @person.name\u003c/pre\u003e\n\nWould be translated into:\n\n    !!!html\n    \u003cpre class=\"ruby-syntax\"\u003eputs @person.name\u003c/pre\u003e\n\nThe +lang+ attribute may only contain letters, so \"Objective-C\", for\nexample would need to be written as \"objc\" or similar.\n\n== External links\n\n    !!!wikitext\n    [http://example.com/ this site]\n\nWould become:\n\n    !!!html\n    \u003ca href=\"http://example.com/\" class=\"external\"\u003ethis site\u003c/a\u003e\n\nSee the {Wikitext::Parser} attributes documentation for information on\noverriding the default external link class (+external+ in this\nexample), or including a +rel+ attribute of \"nofollow\" (which may be\nuseful for search-engine optimization).\n\nNote that in addition to providing a fully-qualified URL including a\nprotocol (such as \"http://\" or \"ftp://\") you also have the option of\nusing an unqualified \"path\"-style URL. This is useful for making\nlinks to other pages still on the same site, but outside of the wiki:\n\n    !!!wikitext\n    [/issues/1024 ticket #1024]\n\nWould become:\n\n    !!!html\n    \u003ca href=\"/issues/1024\"\u003eticket #1024\u003c/a\u003e\n\nNote that no \"external\" class is included in the generated link.\n\nTo avoid false positives, what constitutes a \"path\" is\nnarrowly-defined as a string that begins with a slash, optionally\nfollowed by zero or more \"path components\" consisting of upper and\nlowercase letters, numbers, underscores, hyphens or periods. Path\ncomponents are separated by a slash, and the trailing slash after\nthe last path component is optional.\n\n== Images\n\n    !!!wikitext\n    {{foo.png}}\n\nWhen outputting using HTML syntax (the default), this would become:\n\n    !!!html\n    \u003cimg src=\"/images/foo.png\" alt=\"foo.png\"\u003e\n\nWhen outputting using XML syntax, this would become a self-closing tag:\n\n    !!!html\n    \u003cimg src=\"/images/foo.png\" alt=\"foo.png\" /\u003e\n\nSee the Wikitext::Parser documentation for information on setting the\noutput syntax.\n\nYou can override the \"/images/\" prefix using the +img_prefix+ attribute\nof the Parser.\n\nYou can also specify \"absolute\" image \"src\" attributes regardless of\nthe current prefix setting by starting the image path with a forward\nslash; that is:\n\n    !!!wikitext\n    {{/foo.png}}\n\nWould become:\n\n    !!!html\n    \u003cimg src=\"/foo.png\" alt=\"/foo.png\"\u003e\n\n== Lists\n\nLists come in both unordered (\"ul\"):\n\n    !!!wikitext\n    * item\n    * item\n    * item\n\nAnd ordered (\"ol\") forms:\n\n    !!!wikitext\n    # first\n    # second\n    # third\n\nThese would produce, respectively:\n\n    !!!html\n    \u003cul\u003e\n      \u003cli\u003eitem\u003c/li\u003e\n      \u003cli\u003eitem\u003c/li\u003e\n      \u003cli\u003eitem\u003c/li\u003e\n    \u003c/ul\u003e\n\nAnd:\n\n    !!!html\n    \u003col\u003e\n      \u003cli\u003efirst\u003c/li\u003e\n      \u003cli\u003esecond\u003c/li\u003e\n      \u003cli\u003ethird\u003c/li\u003e\n    \u003c/ol\u003e\n\nLists may be nested inside one another as needed. For example:\n\n    !!!wikitext\n    # outer a\n    # outer b\n    #* nested 1\n    #* nested 2\n    # outer c\n    ## nested foo\n    ## nested bar\n    ##* x\n    ##* y\n    ##** z\n\nWould produce:\n\n    !!!html\n    \u003col\u003e\n      \u003cli\u003eouter a\u003c/li\u003e\n      \u003cli\u003eouter b\n        \u003cul\u003e\n          \u003cli\u003enested 1\u003c/li\u003e\n          \u003cli\u003enested 2\u003c/li\u003e\n        \u003c/ul\u003e\n      \u003c/li\u003e\n      \u003cli\u003eouter c\n        \u003col\u003e\n          \u003cli\u003enested foo\u003c/li\u003e\n          \u003cli\u003enested bar\n            \u003cul\u003e\n              \u003cli\u003ex\u003c/li\u003e\n              \u003cli\u003ey\n                \u003cul\u003e\n                  \u003cli\u003ez\u003c/li\u003e\n                \u003c/ul\u003e\n              \u003c/li\u003e\n            \u003c/ul\u003e\n          \u003c/li\u003e\n        \u003c/ol\u003e\n      \u003c/li\u003e\n    \u003c/ol\u003e\n\n= Ruby support\n\nVersion 4.0.0 and above target Ruby 2.0.0 or higher.\n\nFor older versions of Ruby, you may use the 3.1 release or older.\n\n= Rails support\n\nThe Wikitext extension provides a template handler so that templates named\nfollowing the \u003ctt\u003etemplate_name.html.wikitext\u003c/tt\u003e format will automatically be\ntranslated from wikitext markup into HTML when rendered.\n\nAdditionally, an optional Haml filter is available if you \u003ctt\u003erequire\n\"wikitext/haml_filter\"\u003c/tt\u003e, which enables you to write wikitext markup inline\n(in Haml):\n\n    :wikitext\n      = Here is some [[wikitext]] =\n\nLikewise, a +to_wikitext+ method (aliased as +w+) is added to the +String+\nclass (and also +NilClass+, for convenience) so that content can be easily\ntranslated from inside view templates following patterns like:\n\n    @post.body.w\n\nThe +to_wikitext+ method will preprocess its string using the\nString#wikitext_preprocess method, if it is defined, before feeding the string\nthrough the parser. This can be used to add application-specific behavior such\nas converting special strings like:\n\n    !!!wikitext\n    ticket #1234\n\ninto links. An example preprocessor is included with the extension but it is\nnot active by default; it can be activated with:\n\n    require 'wikitext/preprocess'\n\nFinally, a Wikitext::Parser#shared_parser method is added to provide\nconvenient access to a shared singleton instance of the parser so as to\navoid repeatedly instantiating and setting up new parser instances as part\nof every request.\n\n== Rails 2.3\n\nFor Rails 2.3.x support, use version 2.1.x of the Wikitext gem.\n\nThe plug-in can be activated with an appropriate \u003ctt\u003econfig.gem\u003c/tt\u003e statement\nin your \u003ctt\u003econfig/environment.rb\u003c/tt\u003e:\n\n    config.gem 'wikitext', '2.1.1'\n\n== Rails 3.0\n\nFor Rails 3.0.x support, use version 2.1.x of the Wikitext gem.\n\nAdd a line like the following to your Gemfile:\n\n    gem 'wikitext', '~\u003e 2.1.1'\n\nNote that while older versions of Wikitext do work with Rails 3 to some degree,\nfor full compatibility Wikitext version 2.0 or higher should be used.\n\n== Rails 3.1\n\nAdd a line like the following to your Gemfile:\n\n  gem 'wikitext'\n\n= Links\n\n* Website: http://wincent.github.io/wikitext/\n* RDoc: http://wincent.github.io/wikitext/\n* Source: https://github.com/wincent/wikitext\n\n= Author\n\nWikitext is written and maintained by Greg Hurrell (greg@hurrell.net).\nOther contributors that have submitted patches include:\n\n* Mike Stangel\n\n= License\n\nCopyright 2007-present Greg Hurrell. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\n= Feedback\n\nPlease let me know if you're using the Wikitext extension in your project.\nIf you have any bug reports or feature requests please open a ticket in\nthe issue tracker at https://github.com/wincent/wikitext/issues.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwincent%2Fwikitext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwincent%2Fwikitext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwincent%2Fwikitext/lists"}