pax_global_header00006660000000000000000000000064150562314000014506gustar00rootroot0000000000000052 comment=f1623560ea584b987ef118199f7eacb6cdf14c83 hikidoc-0.1.1/000077500000000000000000000000001505623140000131175ustar00rootroot00000000000000hikidoc-0.1.1/.github/000077500000000000000000000000001505623140000144575ustar00rootroot00000000000000hikidoc-0.1.1/.github/workflows/000077500000000000000000000000001505623140000165145ustar00rootroot00000000000000hikidoc-0.1.1/.github/workflows/release.yaml000066400000000000000000000022511505623140000210200ustar00rootroot00000000000000name: Release on: push: tags: - "*" jobs: github: name: GitHub runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v5 - name: Extract release note run: | ruby \ -e 'print("## HikiDoc "); \ puts(ARGF.read.split(/^!! /)[1])' \ NEWS > release-note.md - name: Upload to release env: GH_TOKEN: ${{ github.token }} run: | title=$(head -n1 release-note.md | sed -e 's/^## //') tail -n +2 release-note.md > release-note-without-version.md gh release create ${GITHUB_REF_NAME} \ --notes-file release-note-without-version.md \ --title "${title}" rubygems: name: RubyGems runs-on: ubuntu-latest timeout-minutes: 10 permissions: id-token: write environment: release steps: - uses: actions/checkout@v5 - uses: ruby/setup-ruby@v1 with: ruby-version: ruby bundler-cache: true - uses: rubygems/configure-rubygems-credentials@v1.0.0 - name: Push gems run: | bundle exec rake release:rubygem_push hikidoc-0.1.1/.gitignore000066400000000000000000000002321505623140000151040ustar00rootroot00000000000000*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp hikidoc-0.1.1/.travis.yml000066400000000000000000000001401505623140000152230ustar00rootroot00000000000000language: ruby rvm: - 1.9.3 - 2.0.0 - 2.1.0 - ruby-head script: bundle exec rake test hikidoc-0.1.1/COPYING000066400000000000000000000027761505623140000141660ustar00rootroot00000000000000Copyright (c) 2005, Kazuhiko All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HikiDoc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hikidoc-0.1.1/Gemfile000066400000000000000000000001341505623140000144100ustar00rootroot00000000000000source 'https://rubygems.org' # Specify your gem's dependencies in hikidoc.gemspec gemspec hikidoc-0.1.1/NEWS000066400000000000000000000021201505623140000136110ustar00rootroot00000000000000! NEWS !! 0.1.1: 2025-09-04 * Fixed license information in gem * Fixed a WikiName escape bug (GH-10, Patch by HASHIMOTO, Naoki) * Suppressed "literal string will be frozen" warnings (GH-12, Reported by Mamoru TASAKA) !! Changes 0.0.6 from 0.0.5: 2010-08-28 * fix missing NEWS.ja for packaging !! Changes 0.0.5 from 0.0.4: 2010-08-26 * fix a bug: strings after non-WikiName expression are ignored * new text decoration ``monospaced text`` * fix rake failure with Hoe 1.9.0 or later * add syntax highlighting with google-code-prettify !! Changes 0.0.4 from 0.0.3: 2009-08-17 * escape collectly in inline_plugin same as block_plugin does. * fix a DoS vulnerability processing a plugin expression. !! Changes 0.0.3 from 0.0.2: 2008-08-25 * fix warning message "Could not find main page README.txt" at installation via gem !! Changes 0.0.2 from 0.0.1: 2008-08-11 * fix a bug: an inline that is inside of a modifier inline do not works * add a option "--no-wikiname" to `hikidoc' command * correct URI scheme behavior of InterWikiName * add some tests * add a Rake task "coverage" (requires rcov) hikidoc-0.1.1/NEWS.ja000066400000000000000000000021631505623140000142110ustar00rootroot00000000000000! NEWS.ja !! 0.1.1: 2025-09-04 * gemのライセンス情報を修正 * WikiNameのエスケープに関する問題を修正(GH-10, HASHIMOTO, Naokiさんがパッチ提供) * "literal string will be frozen"警告を抑制(GH-12, Mamoru TASAKAさんが報告) !! 0.0.5から0.0.6の変更点: 2010-08-28 * パッケージからNEWS.jaが漏れてしまうのを修正 !! 0.0.4から0.0.5の変更点: 2010-08-26 * 同一行に含まれる非WikiName表記以降の文字が出力されないバグを修正 * 新しい文字の修飾``等幅表示``を追加 * Hoe 1.9.0 またはそれ以降でrakeが失敗する問題を修正 * google-code-prettifyでのシンタックスハイライトを追加 !! 0.0.3から0.0.4の変更点: 2009-08-17 * inline_pluginでblock_plugin同様にエスケープするように修正 * プラグイン表記の解釈におけるDoS脆弱性に対する修正 !! 0.0.2から0.0.3の変更点: 2008-08-25 * gemからのインストール時に"Could not find main page README.txt"という警告メッセージが出力され問題を修正 !! 0.0.1から0.0.2の変更点: 2008-08-11 * 修飾系インライン中のインライン記法が展開されないバグを修正 * hikidocコマンドに--no-wikinameオプションを追加 * InterWikiNameでURI schemeとして扱うものをhttp(s),file,ftpに限定するよう修正 * テストを強化 * Rakeタスクcoverageを追加(要rcov) hikidoc-0.1.1/README000066400000000000000000000062061505623140000140030ustar00rootroot00000000000000! HikiDoc !! Introduction 'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML (or XHTML). !! Requirements HikiDoc requires Ruby 1.8.2 or later. !! Download Get from the GitHub repository https://github.com/hiki/hikidoc (eg.) git clone https://github.com/hiki/hikidoc.git !! Installation !!! Semi-manual installation Run the 'setup.rb' script like so: $ ruby setup.rb config $ ruby setup.rb setup # ruby setup.rb install !!! Installation via RubyGems Run the following command: $ gem install hikidoc !! Syntax See [[TextFormattingRules]]. !! Mailing list To subscribe the HikiDoc ML, please send the following mail. English posts are also welcome. To: hikidoc@ml.fdiary.net Cc: kazuhiko@fdiary.net Subject: subscribe <- any subject Hello. <- any body HikiDoc ML's archive is available at http://www.fdiary.net/ml/hikidoc/ . !! Related softwares The following softwares use the HikiDoc library or the HikiDoc format. :[[tDiary|http://www.tdiary.org/]]:a Weblog/Web-diary software :[[Hiki|http://hikiwiki.org/]]:a powerful and fast wiki clone :[[lily|http://lily.sourceforge.jp/]]:a simple CMS :[[Text::HikiDoc|http://search.cpan.org/perldoc?Text::HikiDoc]]:HikiDoc by Perl :[[PikiDoc|http://github.com/moro/piki_doc/]]:a library that you can add plugin functions on HikiDoc :[[mail2weblog|http://sourceforge.jp/projects/mail2weblog/wiki/FrontPage]]:a blog system via mobile phone email !! License HikiDoc's license is the 'Modified BSD License'. Copyright (c) 2005, Kazuhiko All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HikiDoc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hikidoc-0.1.1/README.ja000066400000000000000000000060671505623140000144010ustar00rootroot00000000000000! HikiDoc !! はじめに 'HikiDoc' は「テキスト→ HTML」変換ツールです。書きやすく読みやすい文法の テキストをまともな HTML (や XHTML) に変換します。 !! 必要なもの HikiDoc の実行には Ruby 1.8.2 以降が必要です。 !! ダウンロード GitHub レポジトリ https://github.com/hiki/hikidoc から取得して ください。 (例) git clone https://github.com/hiki/hikidoc.git !! インストール !!! 半手動でのインストール 以下のように 'setup.rb' スクリプトを用いてインストールします。 $ ruby setup.rb config $ ruby setup.rb setup # ruby setup.rb install !!! RubyGems経由でのインストール 以下のようにインストールします。 $ gem install hikidoc !! 文法 [[TextFormattingRules.ja]] をご覧ください。 !! メーリングリスト 参加を希望される方は、以下のようなメールを送信してください。 To: hikidoc@ml.fdiary.net Cc: kazuhiko@fdiary.net 本文に自己紹介など 過去のメールは http://www.fdiary.net/ml/hikidoc/ で公開しています。 !! 関連するソフトウェア 以下のソフトウェアで HikiDoc ライブラリ、または HikiDoc フォーマットが用いられています。 :[[tDiary|http://www.tdiary.org/]]:ウェブ日記ソフトウェア :[[Hiki|http://hikiwiki.org/]]:多機能かつ高速な Wiki クローン :[[lily|http://lily.sourceforge.jp/]]:シンプルな CMS (Web サイト構築システム) :[[Text::HikiDoc|http://search.cpan.org/perldoc?Text::HikiDoc]]:Perl による HikiDoc の実装 :[[PikiDoc|http://github.com/moro/piki_doc/]]:HikiDocの「プラグイン」機能を追加できるライブラリです :[[mail2weblog|http://sourceforge.jp/projects/mail2weblog/wiki/FrontPage]]:高機能メール投稿型モブログ !! ライセンス Modified BSD ライセンスです。 Copyright (c) 2005, Kazuhiko All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HikiDoc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. hikidoc-0.1.1/README.ja.md000066400000000000000000000072671505623140000150030ustar00rootroot00000000000000# HikiDoc ## 'HikiDoc' 鴻 HTML紊若с吾顄帥羈 鴻障 HTML ( XHTML) 紊障 ## 綽荀 HikiDoc 絎茵 Ruby 1.8.2 篁ラ綽荀с ## 潟若 GitHub 吾 [https://github.com/hiki/hikidoc](https://github.com/hiki/hikidoc) 緇 ``` (箴) git clone https://github.com/hiki/hikidoc.git ``` ## ゃ潟鴻若 ### сゃ潟鴻若 篁ヤ 'setup.rb' 鴻ゃ潟鴻若障 ``` $ ruby setup.rb config $ ruby setup.rb setup # ruby setup.rb install ``` ### RubyGems腟宴сゃ潟鴻若 篁ヤゃ潟鴻若障 ``` $ gem install hikidoc ``` ## 羈 [TextFormattingRules.ja](TextFormattingRules.ja) 荀с ## <若潟違鴻 絽鴻篁ヤ<若篆< ``` To: hikidoc@ml.fdiary.net Cc: kazuhiko@fdiary.net 綏援換篁 ``` サ<若 [http://www.fdiary.net/ml/hikidoc/](http://www.fdiary.net/ml/hikidoc/) у障 ## ∫c純с 篁ヤ純с≪ HikiDoc ゃ障 HikiDoc 若障
tDiary
сヨ純с
Hiki
紊罘純ら Wiki 若
lily
激潟 CMS (Web 泣ゃ罕膀激鴻)
Text::HikiDoc
Perl HikiDoc 絎茖
PikiDoc
HikiDoc違ゃ潟罘純菴遵сゃс
mail2weblog
蕭罘純<若腮水≪
## ゃ祉潟 Modified BSD ゃ祉潟鴻с ``` Copyright (c) 2005, Kazuhiko All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HikiDoc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` hikidoc-0.1.1/README.md000066400000000000000000000066201505623140000144020ustar00rootroot00000000000000# HikiDoc ## Introduction 'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML (or XHTML). ## Requirements HikiDoc requires Ruby 1.8.2 or later. ## Download Get from the GitHub repository [https://github.com/hiki/hikidoc](https://github.com/hiki/hikidoc) ``` (eg.) git clone https://github.com/hiki/hikidoc.git ``` ## Installation ### Semi-manual installation Run the 'setup.rb' script like so: ``` $ ruby setup.rb config $ ruby setup.rb setup # ruby setup.rb install ``` ### Installation via RubyGems Run the following command: ``` $ gem install hikidoc ``` ## Syntax See [TextFormattingRules](TextFormattingRules). ## Mailing list To subscribe the HikiDoc ML, please send the following mail. English posts are also welcome. ``` To: hikidoc@ml.fdiary.net Cc: kazuhiko@fdiary.net Subject: subscribe <- any subject Hello. <- any body ``` HikiDoc ML's archive is available at [http://www.fdiary.net/ml/hikidoc/](http://www.fdiary.net/ml/hikidoc/) . ## Related softwares The following softwares use the HikiDoc library or the HikiDoc format.
tDiary
a Weblog/Web-diary software
Hiki
a powerful and fast wiki clone
lily
a simple CMS
Text::HikiDoc
HikiDoc by Perl
PikiDoc
a library that you can add plugin functions on HikiDoc
mail2weblog
a blog system via mobile phone email
## License HikiDoc's license is the 'Modified BSD License'. ``` Copyright (c) 2005, Kazuhiko All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the HikiDoc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ``` hikidoc-0.1.1/Rakefile000066400000000000000000000010041505623140000145570ustar00rootroot00000000000000require "bundler/gem_tasks" require 'rake/testtask' release_task = Rake.application["release"] # We use Trusted Publishing. release_task.prerequisites.delete("build") release_task.prerequisites.delete("release:rubygem_push") release_task_comment = release_task.comment if release_task_comment release_task.clear_comments release_task.comment = release_task_comment.gsub(/ and build.*$/, "") end Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList['test/**/*_test.rb'] t.verbose = true end hikidoc-0.1.1/TextFormattingRules000066400000000000000000000154561505623140000170470ustar00rootroot00000000000000!Paragraphs Consecutive lines are concatenated into a single paragraph. Blank lines (ones with only a carriage return or with only spaces and tabs) mark the end of a paragraph. *Example statement For example, if I write like this, these lines will be formatted as one paragraph. *Example output For example, if I write like this, these lines will be formatted as one paragraph. !Links !!WikiNames WikiNames are comprised of two or more words put together; each word begins with an uppercase letter, and is followed by at least one lowercase letter or number. Words in which this condition is met become a WikiName, and a link is automatically attached. *Example statement WikiName - WikiName HogeRule1 - WikiName NOTWIKINAME - All of the letters are uppercase, so this is not a WikiName WikiNAME - All of the letters in NAME are uppercase, so this is not a WikiName fooWikiName - This begins with "foo", which is in all lowercase, so this is not a WikiName *Example output **WikiName - WikiName **HogeRule1 - WikiName **NOTWIKINAME - All of the letters are uppercase, so this is not a WikiName **WikiNAME - All of the letters in NAME are uppercase, so this is not a WikiName **fooWikiName - This begins with "foo", which is in all lowercase, so this is not a WikiName You can disable an auto WikiName link by putting ''^'' to the WikiName. *Example statement WikiName - WikiName ^WikiName - Disable WikiName link *Example output **WikiName - WikiName **^WikiName - Disable WikiName link !!Linking to other Wiki pages If a page name is surrounded with two pairs of brackets, it becomes a link to that page. *Example statement For example, if you write [[TextFormattingRules]], it becomes a link to that page. *Example output For example, if you write [[TextFormattingRules]], it becomes a link to that page. !!Linking to an arbitrary URL If a phrase and URL, separated by a vertical line, are surrounded with two pairs of brackets, it becomes a link to an arbitrary URL. *Example statement Links like [[Yahoo!|http://www.yahoo.com/]] are also possible. *Example output Links like [[Yahoo!|http://www.yahoo.com/]] are also possible. Text in a paragraph that looks like a URL will automatically become a link. *Example statement Hiki's home page is http://hikiwiki.org/en/ (English). *Example output Hiki's home page is http://hikiwiki.org/en/ (English). In this case, if the URL ends with jpg., .jpeg, .png, or .gif, the image is displayed on the page. *Example statement http://jp.rubyist.net/theme/clover/clover_h1.png *Example output http://jp.rubyist.net/theme/clover/clover_h1.png !Preformatted text Lines beginning with spaces or tabs will be treated as preformatted text. *Example output require 'cgi' cgi = CGI::new cgi.header puts < Hello!

Hello!

EOS !Text decoration Text surrounded by sets of two single quotes ('') is emphasised. Text surrounded by sets of three single quotes (''') is strongly emphasised. Text surrounded by sets of double equal signs (===) is struck out. Text surrounded by sets of double backquotes (``) is inline literal. *Example statement If you write like this, it becomes ''emphasised''. And if you write like this, it becomes '''strongly emphasised'''. ==This is dull, but== And struck-out text is supported, too! If you write like this, it becomes ``monospaced text``. *Example output If you write like this, it becomes ''emphasised''. And if you write like this, it becomes '''strongly emphasised'''. ==This is dull, but== And struck-out text is supported, too! If you write like this, it becomes ``monospaced text``. !Headings Lines with exclamation marks at the beginning become headings. One can use up to six exclamation marks; they will be converted to

to

tags. *Example statement !Heading1 !!Heading2 !!!Heading3 !!!!Heading4 !!!!!Heading5 *Example output !Heading1 !!Heading2 !!!Heading3 !!!!Heading4 !!!!!Heading5 !Horizontal lines Four hyphens at the beginning of the line (----) become a horizontal rule. *Example statement A B C D E ---- F G H I J *Example output A B C D E ---- F G H I J !Lists Lines beginning with asterisks become list items. It is possible to use up to three asterisks; it is also possible to create nested lists. Lines beginning with a # become numbered lists. *Example statement *Item 1 **Item 1.1 **Item 1.2 ***Item 1.2.1 ***Item 1.2.2 ***Item 1.2.3 **Item 1.3 **Item 1.4 *Item 2 #Item 1 #Item 2 ##Item 2.1 ##Item 2.2 ##Item 2.3 #Item 3 ##Item 3.1 ###Item 3.1.1 ###Item 3.1.2 *Example output *Item 1 **Item 1.1 **Item 1.2 ***Item 1.2.1 ***Item 1.2.2 ***Item 1.2.3 **Item 1.3 **Item 1.4 *Item 2 #Item 1 #Item 2 ##Item 2.1 ##Item 2.2 ##Item 2.3 #Item 3 ##Item 3.1 ###Item 3.1.1 ###Item 3.1.2 !Quotations Lines beginning with two double quotes become quotations. *Example statement ""This is a quotation. ""This is another quote. ""This is a continued quote. When there are consecutive quotations, ""they are displayed as one quote, ""like this. *Example output ""This is a quotation. ""This is another quote. ""This is a continued quote. When there are consecutive quotations, ""they are displayed as one quote, ""like this. !Definitions Lines beginning with a colon and have a phrase and explanation separated by another colon will become a definition. *Example statement :ringo:apple :gorira:gorilla :rakuda:camel *Example output :ringo:apple :gorira:gorilla :rakuda:camel ! Tables Tables begin with two vertical bars. Leading `!' in a cell means that it is a heading cell. To concatenate columns or rows, put `>'(columns) or `^'(rows) at head of the cell. * Example statement ||!row heading \ column heading||!column A||!column B||!column C||!>column D-E (horizontal concatenation) ||!row 1||A1||B1||^C1-C2 (vertical concatenation)||D1||E1 ||!row 2||A2||B2||^>D2-E2-D3-E3 (vertical and horizontal concatenation) ||!row 3||>>A3-C3 (horizontal concatenation) * Example output ||!row heading \ column heading||!column A||!column B||!column C||!>column D-E (horizontal concatenation) ||!row 1||A1||B1||^C1-C2 (vertical concatenation)||D1||E1 ||!row 2||A2||B2||^>D2-E2-D3-E3 (vertical and horizontal concatenation) ||!row 3||>>A3-C3 (horizontal concatenation) ! Comments Lines starting with `//' becomes a comment line. Comment lines is not outputted. * Example statement // This is a comment line. * Example output (not displayed) // This is a comment line. !Plugins One can use a plugin by surrounding text with two pairs of brackets. Multiple lines parameter is supported. When a line contains plugin only, it becomes a block plugin, which is not surrounded by

...

. *Example statement {{recent(3)}} * Example statement of multiple lines {{pre(' ... ')}} hikidoc-0.1.1/TextFormattingRules.ja000066400000000000000000000126471505623140000174370ustar00rootroot00000000000000!パラグラフ 連続した複数行は連結されて一つのパラグラフになります。 空行 (改行のみ、またはスペース、タブだけの行) はパラグラフの区切りになります。 *記述例 例えば、 こういう風に記述すると、これらの行は 一つのパラグラフとして整形されます。 *出力例 例えば、 こういう風に記述すると、これらの行は 一つのパラグラフとして整形されます。 !リンク !!WikiName 大文字の英字で始まり、小文字の英字または数字が1文字以上続く この条件が2回以上繰り返される単語はWikiNameになり自動的にリンクがはられます。 *記述例 WikiName - WikiName HogeRule1 - WikiName NOTWIKINAME - 全て大文字なのでWikiNameではない WikiNAME - NAMEが全て大文字なのでWikiNameではない fooWikiName - 先頭に全て小文字の英字fooがあるためWikiNameではない *出力例 **WikiName - WikiName **HogeRule1 - WikiName **NOTWIKINAME - 全て大文字なのでWikiNameではない **WikiNAME - NAMEが全て大文字なのでWikiNameではない **fooWikiName - 先頭に全て小文字の英字fooがあるためWikiNameではない WikiNameの前に''^''をつけるとWikiNameへのリンクを抑制することができます。 *記述例 WikiName - WikiName ^WikiName - WikiNameへのリンクを抑制 *出力例 **WikiName - WikiName **^WikiName - WikiNameへのリンクを抑制 !!ページへのリンク ページ名を二つのカギカッコで囲むと、そのページへのリンクになります。 *記述例 例えば[[逆引きRuby]]とすると、そのページへのリンクになります。 *出力例 例えば[[逆引きRuby]]とすると、そのページへのリンクになります。 !!任意のURLへのリンク 単語|URLを二つのカギカッコで囲むとを任意のURLへのリンクになります。 *記述例 [[Yahoo!|http://www.yahoo.co.jp/]]とかもできます。 *出力例 [[Yahoo!|http://www.yahoo.co.jp/]]とかもできます。 パラグラフ中にURLっぽいものがあると勝手にリンクがはられます。 *記述例 Hikiのページはhttp://hikiwiki.org/ja/です。 *出力例 Hikiのページはhttp://hikiwiki.org/ja/です。 このときURLの末尾がjpg,jpeg,png,gifだとIMGタグに展開されます。 *記述例 http://jp.rubyist.net/theme/clover/clover_h1.png *出力例 http://jp.rubyist.net/theme/clover/clover_h1.png !整形済みテキスト 行の先頭がスペースまたはタブで始まっていると、その行は整形済みとして扱われます。 *出力例 require 'cgi' cgi = CGI::new cgi.header puts < Hello!

Hello!

EOS !文字の修飾 「'」2個ではさんだ部分は強調されます。 「'」3個ではさんだ部分はさらに強調されます。 「=」2個ではさんだ部分は取消線になります。 「`」2個ではさんだ部分は等幅表示になります。 *記述例 このようにすると''強調''になります。 そして、このようにすると'''さらに強調'''されます。 ==だるいけど==さらに、取り消し線もサポートしています。 またまた、このようにすると``等幅表示``になります。 *出力例 このようにすると''強調''になります。 そして、このようにすると'''さらに強調'''されます。 ==だるいけど==さらに、取り消し線もサポートしています。 またまた、このようにすると``等幅表示``になります。 !見出し 「!」を行の先頭に書くと見出しになります。 「!」は一つから六つまで記述することが可能で、それぞれ

に変換されます。 *記述例 !見出し1 !!見出し2 !!!見出し3 !!!!見出し4 !!!!!見出し5 *出力例 !見出し1 !!見出し2 !!!見出し3 !!!!見出し4 !!!!!見出し5 !水平線 マイナス記号「-」を行の先頭から4つ書くと水平線になります。 *記述例 あいうえお。 ---- かきくけこ。 *出力例 あいうえお。 ---- かきくけこ。 !箇条書き 「*」を行の先頭に書くと箇条書きになります。 「*」は一つから三つまで記述することが可能で入れ子にすることもできます。 「#」を行の先頭に書くと番号付きの箇条書きになります。 *記述例 *アイテム1 **アイテム1.1 **アイテム1.2 ***アイテム1.2.1 ***アイテム1.2.2 ***アイテム1.2.3 **アイテム1.3 **アイテム1.4 *アイテム2 #その1 #その2 ##その2.1 ##その2.2 ##その2.3 #その3 ##その3.1 ###その3.1.1 ###その3.1.2 *出力例 *アイテム1 **アイテム1.1 **アイテム1.2 ***アイテム1.2.1 ***アイテム1.2.2 ***アイテム1.2.3 **アイテム1.3 **アイテム1.4 *アイテム2 #その1 #その2 ##その2.1 ##その2.2 ##その2.3 #その3 ##その3.1 ###その3.1.1 ###その3.1.2 !引用 「"」を行の先頭から二つ書くと引用になります。 *記述例 ""これは引用です。 ""さらに引用します。 ""続けて引用します。引用が連続する場合、 ""このように一つの引用として ""展開されます。 *出力例 ""これは引用です。 ""さらに引用します。 ""続けて引用します。引用が連続する場合、 ""このように一つの引用として ""展開されます。 !用語解説 コロン「:」を行の先頭に書き、続けて用語:解説文とすると用語解説になります。 *記述例 :りんご:apple :ゴリラ:gorilla :ラクダ:camel *出力例 :りんご:apple :ゴリラ:gorilla :ラクダ:camel !表 表(テーブル)は「||」で始めます。 セルの項目の頭に「!」をつけることにより見出しセルになります。 行の連結には「^」を列の連結には「>」を、連結したい数だけセルの項目頭につけてください。 *記述例 ||!行見出し\列見出し||!列-A||!列-B||!列-C||!>列-D-E(横連結) ||!行-1||A1||B1||^C1-C2(縦連結)||D1||E1 ||!行-2||A2||B2||^>D2-E2-D3-E3(縦横連結) ||!行-3||>>A3-C3(横3連結) *出力例 ||!行見出し\列見出し||!列-A||!列-B||!列-C||!>列-D-E(横連結) ||!行-1||A1||B1||^C1-C2(縦連結)||D1||E1 ||!行-2||A2||B2||^>D2-E2-D3-E3(縦横連結) ||!行-3||>>A3-C3(横3連結) !コメント行 「//」が行頭にある行はコメント行になり、出力されなくなります。 *記述例 // ここはコメントです。 *出力例(表示されません) // ここはコメントです。 !プラグイン 「{」二つと「}」二つで囲むとプラグインを呼び出すことができます。 パラメータを複数行に分けて書くことも可能です。 プラグインのみを単独行に書いた場合はブロックプラグインになり、前後に

が付かなくなります。 *記述例 {{recent(3)}} *複数行記述例 {{pre( パラメータ1 パラメータ2 パラメータ3 )}} hikidoc-0.1.1/TextFormattingRules.ja.md000066400000000000000000000205511505623140000200270ustar00rootroot00000000000000# 違 g茲域g筝ゃ違障 腥肴 (壕帥障鴻若鴻帥茵) 違阪障 * 荐菴遺 ``` 箴違 蘂荐菴違茵 筝ゃ違翫就障 ``` * 阪箴

箴違 蘂荐菴違茵 筝ゃ違翫就障

# 潟 ## [WikiName](WikiName) 紊ф絖怨у障絨絖怨障医1絖篁ヤ膓 >散2篁ヤ膵違菴茯WikiName潟障 * 荐菴遺 ``` WikiName - WikiName HogeRule1 - WikiName NOTWIKINAME - 紊ф絖WikiNameс WikiNAME - NAME紊ф絖WikiNameс fooWikiName - 絨絖怨fooWikiNameс ``` * 阪箴 WikiName_^_ゃWikiName吾潟吟с障 * 荐菴遺 ``` WikiName - WikiName ^WikiName - WikiName吾潟 ``` * 阪箴 ## 若吾吾潟 若後篋ゃ潟у蚊若吾吾潟障 * 荐菴遺 ``` 箴[[綣Ruby]]若吾吾潟障 ``` * 阪箴

綣Ruby若吾吾潟障

## 篁紙URL吾潟 茯|URL篋ゃ潟у蚊篁紙URL吾潟障 * 荐菴遺 ``` [[Yahoo!|http://www.yahoo.co.jp/]]с障 ``` * 阪箴

Yahoo!с障

違筝URLc純潟障 * 荐菴遺 ``` Hiki若吾http://hikiwiki.org/ja/с ``` * 阪箴

Hiki若吾http://hikiwiki.org/ja/с

URL絨障jpg,jpeg,png,gifIMG帥違絮障 * 荐菴遺 ``` http://jp.rubyist.net/theme/clover/clover_h1.png ``` * 阪箴

clover_h1.png

#翫就羝帥鴻 茵鴻若鴻障帥у障c茵翫就羝帥宴障 * 阪箴
require 'cgi'

cgi = CGI::new
cgi.header

puts <<EOS
<html>
  <head>
    <title>Hello!</title>
  </head>
  <body>
  <p>Hello!</p>
  </body>
</html>
EOS
# 絖篆蕋 '2с綣決帥障 '3с綣決帥障 =2с羔膩障 `2с膈綛茵腓冴障 * 荐菴遺 ``` ''綣決''障 '''綣決'''障 ====羔膩泣若障 障障``膈綛茵腓``障 ``` * 阪箴

綣決綣決羔膩泣若障 障障膈綛茵腓

# 荀冴 !茵吾荀冴障 !筝ゃゃ障ц菴違純с\\紊障 * 荐菴遺 ``` !荀冴1 !!荀冴2 !!!荀冴3 !!!!荀冴4 !!!!!荀冴5 ``` * 阪箴

荀冴1

荀冴2

荀冴3

荀冴4

荀冴5
# 羂翫抗膩 ゃ壕垩-茵4ゆ吾羂翫抗膩障 * 荐菴遺 ``` ---- ``` * 阪箴


# 膊≧吾 \*茵吾膊≧吾障 \*筝ゃ筝ゃ障ц菴違純уャ絖с障 #茵吾垬膊≧吾障 * 荐菴遺 ``` *≪ゃ1 **≪ゃ1.1 **≪ゃ1.2 ***≪ゃ1.2.1 ***≪ゃ1.2.2 ***≪ゃ1.2.3 **≪ゃ1.3 **≪ゃ1.4 *≪ゃ2 ``` ``` #1 #2 ##2.1 ##2.2 ##2.3 #3 ##3.1 ###3.1.1 ###3.1.2 ``` * 阪箴
  • ≪ゃ1
    • ≪ゃ1.1
    • ≪ゃ1.2
      • ≪ゃ1.2.1
      • ≪ゃ1.2.2
      • ≪ゃ1.2.3
    • ≪ゃ1.3
    • ≪ゃ1.4
  • ≪ゃ2
  1. 1
  2. 2
    1. 2.1
    2. 2.2
    3. 2.3
  3. 3
    1. 3.1
      1. 3.1.1
      2. 3.1.2
# 綣 "茵篋ゆ吾綣障 * 荐菴遺 ``` ""綣с ""綣障 ""膓綣障綣g翫 ""筝ゃ綣 ""絮障 ``` * 阪箴

綣с 綣障 膓綣障綣g翫 筝ゃ綣 絮障

# 茯茹h 潟潟:茵吾膓茯:茹h茯茹h障 * 荐菴遺 ``` ::apple :眼:gorilla ::camel ``` * 阪箴
apple
gorilla
camel
# 茵 茵(若)||у障 祉!ゃ荀冴祉障 茵g^g\>g違祉ゃ * 荐菴遺 ``` ||!茵荀冴鐚弱荀冴||!-A||!-B||!-C||!>-D-E鐚罔g鐚 ||!茵-1||A1||B1||^C1-C2鐚膰g鐚||D1||E1 ||!茵-2||A2||B2||^>D2-E2-D3-E3鐚膰罔g鐚 ||!茵-3||>>A3-C3鐚罔鐚g鐚 ``` * 阪箴
茵荀冴鐚弱荀冴-A-B-C-D-E鐚罔g鐚
茵-1A1B1C1-C2鐚膰g鐚D1E1
茵-2A2B2D2-E2-D3-E3鐚膰罔g鐚
茵-3A3-C3鐚罔鐚g鐚
#潟<潟茵 //茵茵潟<潟茵阪障 * 荐菴遺 ``` // 潟<潟с ``` * 阪箴鐚茵腓冴障鐚 #違ゃ {篋ゃ}篋ゃу蚊違ゃ潟若喝冴с障 <若帥茲域吾純с 違ゃ潟帥茵吾翫違ゃ潟緇\\篁障 * 荐菴遺 ``` {{recent(3)}} ``` * 茲域荐菴遺 ``` {{pre( <若随 <若随 <若随 )}} ``` hikidoc-0.1.1/TextFormattingRules.md000066400000000000000000000201151505623140000174320ustar00rootroot00000000000000# Paragraphs Consecutive lines are concatenated into a single paragraph. Blank lines (ones with only a carriage return or with only spaces and tabs) mark the end of a paragraph. * Example statement ``` For example, if I write like this, these lines will be formatted as one paragraph. ``` * Example output

For example, if I write like this, these lines will be formatted as one paragraph.

# Links ## [WikiNames](WikiNames) [WikiNames](WikiNames) are comprised of two or more words put together; each word begins with an uppercase letter, and is followed by at least one lowercase letter or number. Words in which this condition is met become a [WikiName](WikiName), and a link is automatically attached. * Example statement ``` WikiName - WikiName HogeRule1 - WikiName NOTWIKINAME - All of the letters are uppercase, so this is not a WikiName WikiNAME - All of the letters in NAME are uppercase, so this is not a WikiName fooWikiName - This begins with "foo", which is in all lowercase, so this is not a WikiName ``` * Example output
    • WikiName - WikiName
    • HogeRule1 - WikiName
    • NOTWIKINAME - All of the letters are uppercase, so this is not a WikiName
    • WikiNAME - All of the letters in NAME are uppercase, so this is not a WikiName
    • fooWikiName - This begins with "foo", which is in all lowercase, so this is not a WikiName
You can disable an auto [WikiName](WikiName) link by putting _^_ to the [WikiName](WikiName). * Example statement ``` WikiName - WikiName ^WikiName - Disable WikiName link ``` * Example output ## Linking to other Wiki pages If a page name is surrounded with two pairs of brackets, it becomes a link to that page. * Example statement ``` For example, if you write [[TextFormattingRules]], it becomes a link to that page. ``` * Example output

For example, if you write TextFormattingRules, it becomes a link to that page.

## Linking to an arbitrary URL If a phrase and URL, separated by a vertical line, are surrounded with two pairs of brackets, it becomes a link to an arbitrary URL. * Example statement ``` Links like [[Yahoo!|http://www.yahoo.com/]] are also possible. ``` * Example output

Links like Yahoo! are also possible.

Text in a paragraph that looks like a URL will automatically become a link. * Example statement ``` Hiki's home page is http://hikiwiki.org/en/ (English). ``` * Example output

Hiki's home page is http://hikiwiki.org/en/ (English).

In this case, if the URL ends with jpg., .jpeg, .png, or .gif, the image is displayed on the page. * Example statement ``` http://jp.rubyist.net/theme/clover/clover_h1.png ``` * Example output

clover_h1.png

#Preformatted text Lines beginning with spaces or tabs will be treated as preformatted text. * Example output
require 'cgi'

cgi = CGI::new
cgi.header

puts <<EOS
<html>
  <head>
    <title>Hello!</title>
  </head>
  <body>
  <p>Hello!</p>
  </body>
</html>
EOS
# Text decoration Text surrounded by sets of two single quotes ('') is emphasised. Text surrounded by sets of three single quotes (''') is strongly emphasised. Text surrounded by sets of double equal signs (===) is struck out. Text surrounded by sets of double backquotes (``) is inline literal. * Example statement ``` If you write like this, it becomes ''emphasised''. And if you write like this, it becomes '''strongly emphasised'''. ==This is dull, but== And struck-out text is supported, too! If you write like this, it becomes ``monospaced text``. ``` * Example output

If you write like this, it becomes emphasised. And if you write like this, it becomes strongly emphasised. This is dull, but And struck-out text is supported, too! If you write like this, it becomes monospaced text.

# Headings Lines with exclamation marks at the beginning become headings. One can use up to six exclamation marks; they will be converted to \ to \ tags. * Example statement ``` !Heading1 !!Heading2 !!!Heading3 !!!!Heading4 !!!!!Heading5 ``` * Example output

Heading1

Heading2

Heading3

Heading4

Heading5
# Horizontal lines Four hyphens at the beginning of the line (----) become a horizontal rule. * Example statement ``` A B C D E ---- F G H I J ``` * Example output

A B C D E


F G H I J

# Lists Lines beginning with asterisks become list items. It is possible to use up to three asterisks; it is also possible to create nested lists. Lines beginning with a # become numbered lists. * Example statement ``` *Item 1 **Item 1.1 **Item 1.2 ***Item 1.2.1 ***Item 1.2.2 ***Item 1.2.3 **Item 1.3 **Item 1.4 *Item 2 ``` ``` #Item 1 #Item 2 ##Item 2.1 ##Item 2.2 ##Item 2.3 #Item 3 ##Item 3.1 ###Item 3.1.1 ###Item 3.1.2 ``` * Example output
  • Item 1
    • Item 1.1
    • Item 1.2
      • Item 1.2.1
      • Item 1.2.2
      • Item 1.2.3
    • Item 1.3
    • Item 1.4
  • Item 2
  1. Item 1
  2. Item 2
    1. Item 2.1
    2. Item 2.2
    3. Item 2.3
  3. Item 3
    1. Item 3.1
      1. Item 3.1.1
      2. Item 3.1.2
# Quotations Lines beginning with two double quotes become quotations. * Example statement ``` ""This is a quotation. ""This is another quote. ""This is a continued quote. When there are consecutive quotations, ""they are displayed as one quote, ""like this. ``` * Example output

This is a quotation. This is another quote. This is a continued quote. When there are consecutive quotations, they are displayed as one quote, like this.

# Definitions Lines beginning with a colon and have a phrase and explanation separated by another colon will become a definition. * Example statement ``` :ringo:apple :gorira:gorilla :rakuda:camel ``` * Example output
ringo
apple
gorira
gorilla
rakuda
camel
# Tables Tables begin with two vertical bars. Leading `!' in a cell means that it is a heading cell. To concatenate columns or rows, put `\>'(columns) or `^'(rows) at head of the cell. * Example statement ``` ||!row heading \ column heading||!column A||!column B||!column C||!>column D-E (horizontal concatenation) ||!row 1||A1||B1||^C1-C2 (vertical concatenation)||D1||E1 ||!row 2||A2||B2||^>D2-E2-D3-E3 (vertical and horizontal concatenation) ||!row 3||>>A3-C3 (horizontal concatenation) ``` * Example output
row heading \ column headingcolumn Acolumn Bcolumn Ccolumn D-E (horizontal concatenation)
row 1A1B1C1-C2 (vertical concatenation)D1E1
row 2A2B2D2-E2-D3-E3 (vertical and horizontal concatenation)
row 3A3-C3 (horizontal concatenation)
# Comments Lines starting with `//' becomes a comment line. Comment lines is not outputted. * Example statement ``` // This is a comment line. ``` * Example output (not displayed) #Plugins One can use a plugin by surrounding text with two pairs of brackets. Multiple lines parameter is supported. When a line contains plugin only, it becomes a block plugin, which is not surrounded by \ ... \. * Example statement ``` {{recent(3)}} ``` * Example statement of multiple lines ``` {{pre(' ... ')}} ``` hikidoc-0.1.1/bin/000077500000000000000000000000001505623140000136675ustar00rootroot00000000000000hikidoc-0.1.1/bin/hikidoc000077500000000000000000000023151505623140000152300ustar00rootroot00000000000000#!/usr/bin/env ruby require 'hikidoc' require 'optparse' require 'erb' HTML_TEMPLATE = < <%= title %> <%= body %> EOS def usage "Usage: #$0 [OPTIONS] FILE" end options = {} format_options = {} ARGV.options do |opts| opts.banner = usage opts.on('-f', '--fragment', 'Output HTML fragments only') do options[:fragment] = true end opts.on('-t', '--template=TEMPLATE', 'Specify a HTML template file') do |template| options[:template] = template end opts.on('--no-wikiname', 'Disable WikiName link') do format_options[:use_wiki_name] = false end opts.parse! end case ARGV.size when 0 title, text = '-', $stdin.read when 1 title, text = ARGV[0], File.read(ARGV[0]) else abort ARGV.options.help end body = HikiDoc.to_html(text, format_options) def result(erb, title, body, text) erb.result(binding) end if options[:fragment] puts(body) else template = options[:template] if template source = File.read(template) else source = HTML_TEMPLATE end erb = ERB.new(source) erb.filename = template puts(result(erb, title, body, text)) end hikidoc-0.1.1/hikidoc.gemspec000066400000000000000000000021631505623140000161000ustar00rootroot00000000000000# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'hikidoc' Gem::Specification.new do |spec| spec.name = "hikidoc" spec.version = HikiDoc::VERSION spec.authors = ['Kazuhiko', "SHIBATA Hiroshi"] spec.email = ['kazuhiko@fdiary.net', "shibata.hiroshi@gmail.com"] spec.description = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers.} spec.summary = %q{'HikiDoc' is a text-to-HTML conversion tool for web writers. HikiDoc allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML (or XHTML).} spec.homepage = "https://github.com/hiki/hikidoc" spec.license = "BSD-3-clause" spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] spec.add_development_dependency "bundler" spec.add_development_dependency "rake" spec.add_development_dependency "test-unit" end hikidoc-0.1.1/lib/000077500000000000000000000000001505623140000136655ustar00rootroot00000000000000hikidoc-0.1.1/lib/hikidoc.rb000066400000000000000000000461261505623140000156350ustar00rootroot00000000000000# -*- coding: utf-8 -*- # Copyright (c) 2005, Kazuhiko # Copyright (c) 2007 Minero Aoki # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # * Neither the name of the HikiDoc nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. require "stringio" require "strscan" require "uri" begin require "syntax/convertors/html" rescue LoadError end class HikiDoc VERSION = "0.1.1" class Error < StandardError end class UnexpectedError < Error end def HikiDoc.to_html(src, options = {}) new(HTMLOutput.new(">"), options).compile(src) end def HikiDoc.to_xhtml(src, options = {}) new(HTMLOutput.new(" />"), options).compile(src) end def initialize(output, options = {}) @output = output @options = default_options.merge(options) @header_re = nil @level = options[:level] || 1 @plugin_syntax = options[:plugin_syntax] || method(:valid_plugin_syntax?) end def compile(src) @output.reset escape_plugin_blocks(src) {|escaped| compile_blocks escaped @output.finish } end # for backward compatibility def to_html $stderr.puts("warning: HikiDoc#to_html is deprecated. Please use HikiDoc.to_html or HikiDoc.to_xhtml instead.") self.class.to_html(@output, @options) end private def default_options { allow_bracket_inline_image: true, use_wiki_name: true, use_not_wiki_name: true, } end # # Plugin # def valid_plugin_syntax?(code) /['"]/ !~ code.gsub(/\\\\/, "").gsub(/\\['"]/,"").gsub(/'[^']*'|"[^"]*"/m, "") end def escape_plugin_blocks(text) s = StringScanner.new(text) buf = +"" @plugin_blocks = [] while chunk = s.scan_until(/\{\{/) chunk[-2, 2] = "" buf << chunk if block = extract_plugin_block(s) @plugin_blocks.push block buf << "\0#{@plugin_blocks.size - 1}\0" else buf << "{{" end end buf << s.rest yield(buf) end def restore_plugin_block(str) str.gsub(/\0(\d+)\0/) { "{{" + plugin_block($1.to_i) + "}}" } end def evaluate_plugin_block(str, buf = nil) buf ||= @output.container str.split(/(\0\d+\0)/).each do |s| if s[0, 1] == "\0" and s[-1, 1] == "\0" buf << @output.inline_plugin(plugin_block(s[1..-2].to_i)) else buf << @output.text(s) end end buf end def plugin_block(id) @plugin_blocks[id] or raise UnexpectedError, "must not happen: #{id.inspect}" end def extract_plugin_block(s) pos = s.pos buf = +"" while chunk = s.scan_until(/\}\}/) buf << chunk buf.chomp!("}}") if @plugin_syntax.call(buf) return buf end buf << "}}" end s.pos = pos nil end # # Block Level # def compile_blocks(src) f = LineInput.new(StringIO.new(src)) while line = f.peek case line when COMMENT_RE f.gets when HEADER_RE compile_header f.gets when HRULE_RE f.gets compile_hrule when LIST_RE compile_list f when DLIST_RE compile_dlist f when TABLE_RE compile_table f when BLOCKQUOTE_RE compile_blockquote f when INDENTED_PRE_RE compile_indented_pre f when BLOCK_PRE_OPEN_RE compile_block_pre f else if /^$/ =~ line f.gets next end compile_paragraph f end end end COMMENT_RE = %r<\A//> def skip_comments(f) f.while_match(COMMENT_RE) do |line| end end HEADER_RE = /\A!+/ def compile_header(line) @header_re ||= /\A!{1,#{7 - @level}}/ level = @level + (line.slice!(@header_re).size - 1) title = strip(line) @output.headline level, compile_inline(title) end HRULE_RE = /\A----$/ def compile_hrule @output.hrule end ULIST = "*" OLIST = "#" LIST_RE = /\A#{Regexp.union(ULIST, OLIST)}+/ def compile_list(f) typestack = [] level = 0 @output.list_begin f.while_match(LIST_RE) do |line| list_type = (line[0,1] == ULIST ? "ul" : "ol") new_level = line.slice(LIST_RE).size item = strip(line.sub(LIST_RE, "")) if new_level > level (new_level - level).times do typestack.push list_type @output.list_open list_type @output.listitem_open end @output.listitem compile_inline(item) elsif new_level < level (level - new_level).times do @output.listitem_close @output.list_close typestack.pop end @output.listitem_close @output.listitem_open @output.listitem compile_inline(item) elsif list_type == typestack.last @output.listitem_close @output.listitem_open @output.listitem compile_inline(item) else @output.listitem_close @output.list_close typestack.pop @output.list_open list_type @output.listitem_open @output.listitem compile_inline(item) typestack.push list_type end level = new_level skip_comments f end level.times do @output.listitem_close @output.list_close typestack.pop end @output.list_end end DLIST_RE = /\A:/ def compile_dlist(f) @output.dlist_open f.while_match(DLIST_RE) do |line| dt, dd = split_dlitem(line.sub(DLIST_RE, "")) @output.dlist_item compile_inline(dt), compile_inline(dd) skip_comments f end @output.dlist_close end def split_dlitem(line) re = /\A((?:#{BRACKET_LINK_RE}|.)*?):/o if m = re.match(line) return m[1], m.post_match else return line, "" end end TABLE_RE = /\A\|\|/ def compile_table(f) lines = [] f.while_match(TABLE_RE) do |line| lines.push line skip_comments f end @output.table_open lines.each do |line| @output.table_record_open split_columns(line.sub(TABLE_RE, "")).each do |col| mid = col.sub!(/\A!/, "") ? "table_head" : "table_data" span = col.slice!(/\A[\^>]*/) rs = span_count(span, "^") cs = span_count(span, ">") @output.__send__(mid, compile_inline(col), rs, cs) end @output.table_record_close end @output.table_close end def split_columns(str) cols = str.split(/\|\|/) cols.pop if cols.last.chomp.empty? cols end def span_count(str, ch) c = str.count(ch) c == 0 ? nil : c + 1 end BLOCKQUOTE_RE = /\A""[ \t]?/ def compile_blockquote(f) @output.blockquote_open lines = [] f.while_match(BLOCKQUOTE_RE) do |line| lines.push line.sub(BLOCKQUOTE_RE, "") skip_comments f end compile_blocks lines.join("") @output.blockquote_close end INDENTED_PRE_RE = /\A[ \t]/ def compile_indented_pre(f) lines = f.span(INDENTED_PRE_RE)\ .map {|line| rstrip(line.sub(INDENTED_PRE_RE, "")) } text = restore_plugin_block(lines.join("\n")) @output.preformatted(@output.text(text)) end BLOCK_PRE_OPEN_RE = /\A<<<\s*(\w+)?/ BLOCK_PRE_CLOSE_RE = /\A>>>/ def compile_block_pre(f) m = BLOCK_PRE_OPEN_RE.match(f.gets) or raise UnexpectedError, "must not happen" str = restore_plugin_block(f.break(BLOCK_PRE_CLOSE_RE).join.chomp) f.gets @output.block_preformatted(str, m[1]) end BLANK = /\A$/ PARAGRAPH_END_RE = Regexp.union(BLANK, HEADER_RE, HRULE_RE, LIST_RE, DLIST_RE, BLOCKQUOTE_RE, TABLE_RE, INDENTED_PRE_RE, BLOCK_PRE_OPEN_RE) def compile_paragraph(f) lines = f.break(PARAGRAPH_END_RE)\ .reject {|line| COMMENT_RE =~ line } if lines.size == 1 and /\A\0(\d+)\0\z/ =~ strip(lines[0]) @output.block_plugin plugin_block($1.to_i) else line_buffer = @output.container(:paragraph) lines.each_with_index do |line, i| buffer = @output.container line_buffer << buffer compile_inline(lstrip(line).chomp, buffer) end @output.paragraph(line_buffer) end end # # Inline Level # BRACKET_LINK_RE = /\[\[.+?\]\]/ URI_RE = /(?:https?|ftp|file|mailto):[A-Za-z0-9;\/?:@&=+$,\-_.!~*\'()#%]+/ WIKI_NAME_RE = /\b(?:[A-Z]+[a-z\d]+){2,}\b/ def inline_syntax_re if @options[:use_wiki_name] if @options[:use_not_wiki_name] / (#{BRACKET_LINK_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) | (\^?#{WIKI_NAME_RE}) /xo else / (#{BRACKET_LINK_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) | (#{WIKI_NAME_RE}) /xo end else / (#{BRACKET_LINK_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) /xo end end def compile_inline(str, buf = nil) buf ||= @output.container re = inline_syntax_re pending_str = "" while m = re.match(str) str = m.post_match link, uri, mod, wiki_name = m[1, 4] if wiki_name and wiki_name.start_with? "^" pending_str += m.pre_match + wiki_name[1..-1] next end pre_str = "#{pending_str}#{m.pre_match}" pending_str = "" evaluate_plugin_block(pre_str, buf) compile_inline_markup(buf, link, uri, mod, wiki_name) end evaluate_plugin_block(pending_str + str, buf) buf end def compile_inline_markup(buf, link, uri, mod, wiki_name) case when link buf << compile_bracket_link(link[2...-2]) when uri buf << compile_uri_autolink(uri) when mod buf << compile_modifier(mod) when wiki_name buf << @output.wiki_name(wiki_name) else raise UnexpectedError, "must not happen" end end def compile_bracket_link(link) if m = /\A(.*)\|/.match(link) title = m[0].chop uri = m.post_match fixed_uri = fix_uri(uri) if can_image_link?(uri) @output.image_hyperlink(fixed_uri, title) else @output.hyperlink(fixed_uri, compile_modifier(title)) end else fixed_link = fix_uri(link) if can_image_link?(link) @output.image_hyperlink(fixed_link) else @output.hyperlink(fixed_link, @output.text(link)) end end end def can_image_link?(uri) image?(uri) and @options[:allow_bracket_inline_image] end def compile_uri_autolink(uri) if image?(uri) @output.image_hyperlink(fix_uri(uri)) else @output.hyperlink(fix_uri(uri), @output.text(uri)) end end def fix_uri(uri) if /\A(?:https?|ftp|file):(?!\/\/)/ =~ uri uri.sub(/\A\w+:/, "") else uri end end IMAGE_EXTS = %w(.jpg .jpeg .gif .png) def image?(uri) IMAGE_EXTS.include?(uri[/\.[^.]+\z/].to_s.downcase) end STRONG = "'''" EM = "''" DEL = "==" TT = "``" STRONG_RE = /'''.+?'''/ EM_RE = /''.+?''/ DEL_RE = /==.+?==/ TT_RE = /``.+?``/ MODIFIER_RE = Regexp.union(STRONG_RE, EM_RE, DEL_RE, TT_RE) MODTAG = { STRONG => "strong", EM => "em", DEL => "del", TT => 'tt' } def compile_modifier(str) buf = @output.container while m = / (#{MODIFIER_RE}) /xo.match(str) evaluate_plugin_block(m.pre_match, buf) case when chunk = m[1] mod, s = split_mod(chunk) mid = MODTAG[mod] buf << @output.__send__(mid, compile_inline(s)) else raise UnexpectedError, "must not happen" end str = m.post_match end evaluate_plugin_block(str, buf) buf end def split_mod(str) case str when /\A'''/ return str[0, 3], str[3...-3] when /\A''/ return str[0, 2], str[2...-2] when /\A==/ return str[0, 2], str[2...-2] when /\A``/ return str[0, 2], str[2...-2] else raise UnexpectedError, "must not happen: #{str.inspect}" end end def strip(str) rstrip(lstrip(str)) end def rstrip(str) str.sub(/[ \t\r\n\v\f]+\z/, "") end def lstrip(str) str.sub(/\A[ \t\r\n\v\f]+/, "") end class HTMLOutput def initialize(suffix = " />") @suffix = suffix @f = nil end def reset @f = StringIO.new end def finish @f.string end def container(_for=nil) case _for when :paragraph [] else +"" end end # # Procedures # def headline(level, title) @f.puts "#{title}" end def hrule @f.puts "" end def list_close(type) @f.print "" end def listitem_open @f.print "
  • " end def listitem_close @f.puts "
  • " end def listitem(item) @f.print item end def dlist_open @f.puts "
    " end def dlist_close @f.puts "
    " end def dlist_item(dt, dd) case when dd.empty? @f.puts "
    #{dt}
    " when dt.empty? @f.puts "
    #{dd}
    " else @f.puts "
    #{dt}
    " @f.puts "
    #{dd}
    " end end def table_open @f.puts %Q() end def table_close @f.puts "
    " end def table_record_open @f.print "" end def table_record_close @f.puts "" end def table_head(item, rs, cs) @f.print "#{item}" end def table_data(item, rs, cs) @f.print "#{item}" end def tdattr(rs, cs) buf = +"" buf << %Q( rowspan="#{rs}") if rs buf << %Q( colspan="#{cs}") if cs buf end private :tdattr def blockquote_open @f.print "
    " end def blockquote_close @f.puts "
    " end def block_preformatted(str, info) syntax = info ? info.downcase : nil if syntax begin convertor = Syntax::Convertors::HTML.for_syntax(syntax) @f.puts convertor.convert(str) return rescue NameError, RuntimeError @f.puts %Q|
    #{text(str)}
    | return end end preformatted(text(str)) end def preformatted(str) @f.print "
    "
          @f.print str
          @f.puts "
    " end def paragraph(lines) @f.puts "

    #{lines.join("\n")}

    " end def block_plugin(str) @f.puts %Q(
    {{#{escape_html(str)}}}
    ) end # # Functions # def hyperlink(uri, title) %Q(#{title}) end def wiki_name(name) hyperlink(name, text(name)) end def image_hyperlink(uri, alt = nil) alt ||= uri.split(/\//).last alt = escape_html(alt) %Q(#{alt}#{item}" end def em(item) "#{item}" end def del(item) "#{item}" end def tt(item) "#{item}" end def text(str) escape_html(str) end def inline_plugin(src) %Q({{#{escape_html(src)}}}) end # # Utilities # def escape_html_param(str) escape_quote(escape_html(str)) end def escape_html(text) text.gsub(/&/, "&").gsub(//, ">") end def unescape_html(text) text.gsub(/>/, ">").gsub(/</, "<").gsub(/&/, "&") end def escape_quote(text) text.gsub(/"/, """) end end class LineInput def initialize(f) @input = f @buf = [] @lineno = 0 @eof_p = false end def inspect "\#<#{self.class} file=#{@input.inspect} line=#{lineno()}>" end def eof? @eof_p end def lineno @lineno end def gets unless @buf.empty? @lineno += 1 return @buf.pop end return nil if @eof_p # to avoid ARGF blocking. line = @input.gets line = line.sub(/\r\n/, "\n") if line @eof_p = line.nil? @lineno += 1 line end def ungets(line) return unless line @lineno -= 1 @buf.push line line end def peek line = gets() ungets line if line line end def next? peek() ? true : false end def skip_blank_lines n = 0 while line = gets() unless line.strip.empty? ungets line return n end n += 1 end n end def gets_if(re) line = gets() if not line or not (re =~ line) ungets line return nil end line end def gets_unless(re) line = gets() if not line or re =~ line ungets line return nil end line end def each while line = gets() yield line end end def while_match(re) while line = gets() unless re =~ line ungets line return end yield line end nil end def getlines_while(re) buf = [] while_match(re) do |line| buf.push line end buf end alias span getlines_while # from Haskell def until_match(re) while line = gets() if re =~ line ungets line return end yield line end nil end def getlines_until(re) buf = [] until_match(re) do |line| buf.push line end buf end alias break getlines_until # from Haskell def until_terminator(re) while line = gets() return if re =~ line # discard terminal line yield line end nil end def getblock(term_re) buf = [] until_terminator(term_re) do |line| buf.push line end buf end end end if __FILE__ == $0 puts HikiDoc.to_html(ARGF.read(nil)) end hikidoc-0.1.1/test/000077500000000000000000000000001505623140000140765ustar00rootroot00000000000000hikidoc-0.1.1/test/hikidoc_test.rb000066400000000000000000000515541505623140000171060ustar00rootroot00000000000000require "test/unit" rootdir = "#{File::dirname(__FILE__)}/.." require "#{rootdir}/lib/hikidoc" class HikiDocTestCase < Test::Unit::TestCase def test_plugin assert_convert("
    {{hoge}}
    \n", "{{hoge}}") assert_convert("

    a{{hoge}}b

    \n", "a{{hoge}}b") assert_convert("

    \\{{hoge}}

    \n", "\\{{hoge}}") assert_convert("

    a{{hoge

    \n", "a{{hoge") assert_convert("

    hoge}}b

    \n", "hoge}}b") assert_convert("

    {{hoge}}\na

    \n", "{{hoge}}\na") assert_convert("
    {{hoge}}
    \n

    a

    \n", "{{hoge}}\n\na") end def test_plugin_with_quotes assert_convert("
    {{hoge(\"}}\")}}
    \n", '{{hoge("}}")}}') assert_convert("
    {{hoge(\'}}\')}}
    \n", "{{hoge('}}')}}") assert_convert("
    {{hoge(\'\n}}\n\')}}
    \n", "{{hoge('\n}}\n')}}") end def test_plugin_with_meta_char assert_convert("
    {{hoge(\"a\\\"b\")}}
    \n", '{{hoge("a\\"b")}}') assert_convert("
    {{hoge(\"<a>\")}}
    \n", '{{hoge("")}}') assert_convert("

    a{{hoge(\"<a>\")}}

    \n", 'a{{hoge("
    ")}}') end def test_plugin_with_default_syntax # test HikiDoc#valid_plugin_syntax? # default syntax checking pairs of quote like "..." or '...' assert_convert(%q!

    {{'}}

    ! + "\n", %q!{{'}}!) assert_convert(%q!
    {{''}}
    ! + "\n", %q!{{''}}!) assert_convert(%q!

    {{'"}}

    ! + "\n", %q!{{'"}}!) assert_convert(%q!
    {{'\''}}
    ! + "\n", %q!{{'\''}}!) assert_convert(%q!
    {{'abc\\\\'}}
    ! + "\n", %q!{{'abc\\\\'}}!) assert_convert(%q!
    {{\"""}}
    ! + "\n", %q!{{\"""}}!) assert_convert(%q!
    {{"ab\c"}}
    ! + "\n", %q!{{"ab\c"}}!) end def test_plugin_with_custom_syntax assert_convert("

    {{<<\"End\"\nfoo's bar\nEnd\n}}

    \n", "{{<<\"End\"\nfoo's bar\nEnd\n}}") options = {plugin_syntax: method(:custom_valid_plugin_syntax?)} assert_convert(%Q|
    {{<<"End"\nfoo's bar\nEnd\n}}
    \n|, %Q!{{<<"End"\nfoo's bar\nEnd\n}}!, options) assert_convert(%Q|
    {{<<"End"\nfoo\nEnd}}
    \n|, %Q!{{<<"End"\nfoo\nEnd}}!, options) end def test_multi_line_plugin assert_convert(<<-END_OF_EXPECTED, <<-END_OF_INPUT)
    {{<<TEST2 test2 TEST2}}
    END_OF_EXPECTED {{<{{<<TEST <<< here is not pre but plugin. >>> TEST}} END_OF_EXPECTED {{<>> TEST}} END_OF_INPUT end def test_blockquote assert_convert("

    hoge

    \n
    \n", %Q|""hoge\n|) assert_convert("

    hoge\nfuga

    \n
    \n", %Q|""hoge\n""fuga\n|) assert_convert("

    hoge

    \n

    fuga

    \n
    \n
    \n", %Q|""hoge\n"" ""fuga\n|) assert_convert("

    hoge

    \n
    \n", %Q|"" ! hoge\n|) assert_convert("

    foo\nbar

    \n

    foo

    \n
    \n", %Q|""foo\n""bar\n""\n""foo|) assert_convert("

    foo\nbar

    \n

    foo

    \n
    \n", %Q|""foo\n""bar\n""!foo|) assert_convert("

    foo\nbar

    \n
    baz
    \n
    \n", %Q|""foo\n"" bar\n"" baz|) assert_convert("

    foo\nbar

    \n
    baz
    \n
    \n", %Q|""foo\n""\tbar\n""\t\tbaz|) end def test_header assert_convert("

    hoge

    \n", "!hoge") assert_convert("

    hoge

    \n", "!! hoge") assert_convert("

    hoge

    \n", "!!!hoge") assert_convert("

    hoge

    \n", "!!!! hoge") assert_convert("
    hoge
    \n", "!!!!!hoge") assert_convert("
    hoge
    \n", "!!!!!! hoge") assert_convert("
    ! hoge
    \n", "!!!!!!! hoge") assert_convert("

    foo

    \n

    bar

    \n", "!foo\n!!bar") end def test_list assert_convert("
      \n
    • foo
    • \n
    \n", "* foo") assert_convert("
      \n
    • foo
    • \n
    • bar
    • \n
    \n", "* foo\n* bar") assert_convert("
      \n
    • foo
        \n
      • bar
      • \n
    • \n
    \n", "* foo\n** bar") assert_convert("
      \n
    • foo
        \n
      • foo
      • \n
    • \n
    • bar
    • \n
    \n", "* foo\n** foo\n* bar") assert_convert("
      \n
    • foo
        \n
      1. foo
      2. \n
    • \n
    • bar
    • \n
    \n", "* foo\n## foo\n* bar") assert_convert("
      \n
    • foo
    • \n
      \n
    1. bar
    2. \n
    \n", "* foo\n# bar") end def test_list_skip assert_convert("
      \n
    • foo
        \n
        • \n
        • foo
        • \n
      • \n
    • \n
    • bar
    • \n
    \n", "* foo\n*** foo\n* bar") assert_convert("
      \n
    1. foo
        \n
        1. \n
        2. bar
        3. \n
        4. baz
        5. \n
      1. \n
    2. \n
    \n", "# foo\n### bar\n###baz") end def test_hrules assert_convert("
    \n", "----") assert_convert("

    ----a

    \n", "----a") end def test_pre assert_convert("
    foo
    \n", " foo") assert_convert("
    \\:
    \n", ' \:') assert_convert("
    foo
    \n", "\tfoo") assert_convert("
    foo\nbar
    \n", " foo\n bar") assert_convert("
    foo\nbar
    \n", " foo\n bar\n") assert_convert("
    <foo>
    \n", " ") assert_convert("
    {{_:a/a}}
    \n", " {{_:a/a}}") assert_convert("
    [[_:a/a]]
    \n", " [[_:a/a]]") end def test_multi_pre assert_convert("
    foo
    \n", "<<<\nfoo\n>>>") assert_convert("
    foo\n bar
    \n", "<<<\nfoo\n bar\n>>>") assert_convert("
    foo
    \n
    bar
    \n", "<<<\nfoo\n>>>\n<<<\nbar\n>>>") assert_convert("
    <foo>
    \n", "<<<\n\n>>>") end def test_multi_pre_with_plugin assert_convert("
    {{{}}}
    \n" + "
    {{'test'}}
    \n", "<<<\n{{{}}}\n>>>\n{{'test'}}") end def test_comment assert_convert("", "// foo") assert_convert("", "// foo\n") end def test_paragraph assert_convert("

    foo

    \n", "foo") assert_convert("

    foo

    \n

    bar

    \n", "foo\n\nbar") assert_convert("

    foo

    \n

    bar

    \n", "foo\r\n\r\nbar") assert_convert("

    foo

    \n

    b a r

    \n", "foo \n\nb a r ") end def test_escape assert_convert(%Q|

    \\"\\"foo

    \n|, %q|\"\"foo|) end def test_link assert_convert(%Q|

    http://hikiwiki.org/

    \n|, "http://hikiwiki.org/") assert_convert(%Q|

    http://hikiwiki.org/

    \n|, "[[http://hikiwiki.org/]]") assert_convert(%Q|

    Hiki

    \n|, "[[Hiki|http://hikiwiki.org/]]") assert_convert(%Q|

    Hiki

    \n|, "[[Hiki|http:/hikiwiki.html]]") assert_convert(%Q|

    Hiki

    \n|, "[[Hiki|http:hikiwiki.html]]") assert_convert(%Q|

    img.png

    \n|, "http://hikiwiki.org/img.png") assert_convert(%Q|

    img.png

    \n|, "http://hikiwiki.org:80/img.png") assert_convert(%Q|

    | + %Q|http://hikiwiki.org/ja/?c=edit;p=Test

    \n|, "http://hikiwiki.org/ja/?c=edit;p=Test") assert_convert(%Q|

    | + %Q|http://hikiwiki.org/ja/?c=edit&p=Test

    \n|, "http://hikiwiki.org/ja/?c=edit&p=Test") assert_convert(%Q|

    img.png

    \n|, "http:/img.png") assert_convert(%Q|

    img.png

    \n|, "http:img.png") assert_convert(%Q|

    Tuna

    \n|, "[[Tuna|%CB%EE]]") assert_convert(%Q|

    ""

    \n|, '[[""]]') assert_convert(%Q|

    %22

    \n|, "[[%22]]") assert_convert(%Q|

    &

    \n|, "[[&]]") assert_convert(%Q|

    aabbcc

    \n|, "[[aa]]bb[[cc]]") assert_convert(%Q!

    a|a

    \n!, "[[a|a|aa]]") end def test_inter_wiki_name assert_convert("

    scheme:keyword

    \n", "[[scheme:keyword]]") assert_convert("

    label

    \n", "[[label|scheme:keyword]]") end def test_wiki_name assert_convert("

    WikiName

    \n", "WikiName") assert_convert("

    HogeRule1

    \n", "HogeRule1") assert_convert("

    WikiName1WikiName2

    \n", "WikiName1WikiName2") assert_convert("

    WikiName1 " + "WikiName2

    \n", "WikiName1 WikiName2") assert_convert("

    NOTWIKINAME

    \n", "NOTWIKINAME") assert_convert("

    NOT_WIKI_NAME

    \n", "NOT_WIKI_NAME") assert_convert("

    WikiNAME

    \n", "WikiNAME") assert_convert("

    fooWikiNAME

    \n", "fooWikiNAME") assert_convert("

    RSSPage

    \n", "RSSPage") assert_convert("

    RSSPageName

    \n", "RSSPageName") end def test_not_wiki_name assert_convert("

    WikiName

    \n", "^WikiName") assert_convert("

    ^WikiName

    \n", "^WikiName", use_not_wiki_name: false) assert_convert("

    ^WikiName

    \n", "^WikiName", use_wiki_name: false) assert_convert("

    ^WikiName

    \n", "^WikiName", use_wiki_name: false, use_not_wiki_name: false) assert_convert("

    foo WikiName bar

    \n", "foo ^WikiName bar") assert_convert("

    WikiName - Disable WikiName link

    \n", "^WikiName - Disable WikiName link") assert_convert("

    WikiName - Disable DisabledWikiName link

    \n", "WikiName - Disable ^DisabledWikiName link") assert_convert("

    WikiName - Disable WikiName link

    \n", "WikiName - Disable WikiName link") assert_convert("

    DisabledWikiName - Disable DisabledWikiName link

    \n", "^DisabledWikiName - Disable ^DisabledWikiName link") end def test_use_wiki_name_option assert_convert("

    WikiName

    \n", "WikiName") assert_convert("

    WikiName

    \n", "WikiName", use_wiki_name: false) end def test_image_link assert_convert(%Q|

    img.png

    \n|, "[[http://hikiwiki.org/img.png]]") assert_convert(%Q|

    http://hikiwiki.org/img.png

    \n|, "[[http://hikiwiki.org/img.png]]", allow_bracket_inline_image: false) assert_convert(%Q|

    img

    \n|, "[[img|http://hikiwiki.org/img.png]]") assert_convert(%Q|

    img

    \n|, "[[img|http://hikiwiki.org/img.png]]", allow_bracket_inline_image: false) end def test_definition assert_convert("
    \n
    a
    \n
    b
    \n
    \n", ":a:b") assert_convert("
    \n
    a
    \n
    b\n
    \n
    c
    \n
    \n", ":a:b\n::c") assert_convert("
    \n
    a\\
    \n
    b:c
    \n
    \n", ':a\:b:c') assert_convert("
    \n
    a
    \n
    b\\:c
    \n
    \n", ':a:b\:c') assert_convert("
    \n
    a
    \n
    b:c
    \n
    \n", ":a:b:c") end def test_definition_title_only assert_convert("
    \n
    a
    \n
    \n", ":a:") end def test_definition_description_only assert_convert("
    \n
    b
    \n
    \n", "::b") end def test_definition_with_link assert_convert("
    \n
    Hiki
    \n" + "
    Website
    \n
    \n", ":[[Hiki|http://hikiwiki.org/]]:Website") assert_convert("
    \n
    a
    \n" + "
    Hiki
    \n" + "
    \n", ":a:[[Hiki|http://hikiwiki.org/]]") end def test_definition_with_modifier assert_convert("
    \n
    foo
    \n" + "
    bar
    \n
    \n", ":'''foo''':bar") assert_convert("
    \n
    foo
    \n" + "
    bar
    \n
    \n", ":foo:'''bar'''") assert_convert("
    \n
    foo
    \n" + "
    bar
    \n
    \n", ":foo:``bar``") end def test_definition_with_modifier_link assert_convert("
    \n
    " + "Hiki" + "
    \n
    Website
    \n
    \n", ":'''[[Hiki|http://hikiwiki.org/]]''':Website") assert_convert("
    \n
    Website
    \n
    " + "Hiki" + "
    \n
    \n", ":Website:'''[[Hiki|http://hikiwiki.org/]]'''") assert_convert("
    \n
    Website
    \n
    " + "Hiki" + "
    \n
    \n", ":Website:``[[Hiki|http://hikiwiki.org/]]``") end def test_table assert_convert(%Q|\n\n
    ab
    \n|, "||a||b") assert_convert(%Q|\n\n
    ab
    \n|, "||a||b||") assert_convert(%Q|\n\n
    ab
    \n|, "||a||b||") assert_convert(%Q|\n\n
    ab
    \n|, "||a||b|| ") assert_convert(%Q|\n\n
    ab
    \n|, "||!a||b||") assert_convert(%Q|\n\n\n\n
    12\n
    34\n
    5
    \n|, "||>1||^2\n||^3||4\n||>5") assert_convert(%Q|\n\n\n\n
    abc
    def
    \n|, "||a||b||c||\n||||||||\n||d||e||f||") end def test_table_with_modifier assert_convert("\n\n
    ''''''bar
    \n", "||'''||'''||bar") assert_convert("\n\n
    '''\\'''bar
    \n", "||'''\\||'''||bar") end def test_modifier assert_convert("

    foo

    \n", "'''foo'''") assert_convert("

    foo

    \n", "''foo''") assert_convert("

    foo

    \n", "==foo==") assert_convert("

    foo==barbaz==

    \n", "''foo==bar''baz==") assert_convert("

    foo and bar

    \n", "'''foo''' and '''bar'''") assert_convert("

    foo and bar

    \n", "''foo'' and ''bar''") assert_convert("

    foo

    \n", "``foo``") assert_convert("

    foo==barbaz==

    \n", "``foo==bar``baz==") end def test_nested_modifier assert_convert("

    foo

    \n", "''==foo==''") assert_convert("

    foo

    \n", "==''foo''==") end def test_modifier_and_link assert_convert("

    Hiki

    \n", "[['''Hiki'''|http://hikiwiki.org/]]") assert_convert("

    Hiki

    \n", "'''[[Hiki|http://hikiwiki.org/]]'''") assert_convert("

    Hiki

    \n", "``[[Hiki|http://hikiwiki.org/]]``") end def test_pre_and_plugin assert_convert(%Q|
    {{hoge}}
    \n|, " {{hoge}}") assert_convert(%Q|
    {{hoge}}
    \n|, "<<<\n{{hoge}}\n>>>") assert_convert("
    {{foo\n 1}}
    \n", "{{foo\n 1}}") end def test_plugin_in_modifier assert_convert("

    {{foo}}

    \n", "'''{{foo}}'''") assert_convert("

    {{foo}}

    \n", "``{{foo}}``") end def test_syntax_ruby if Object.const_defined?(:Syntax) assert_convert("
    class A\n  def foo(bar)\n  end\nend
    \n", "<<< ruby\nclass A\n def foo(bar)\n end\nend\n>>>") assert_convert("
    class A\n  def foo(bar)\n  end\nend
    \n", "<<< Ruby\nclass A\n def foo(bar)\n end\nend\n>>>") assert_convert("
    'a<">b'
    \n", "<<< ruby\n'a<\">b'\n>>>") # redefine method for below tests class << Syntax::Convertors::HTML def for_syntax(syntax) raise end end end # use google-code-prettify assert_convert("
    class A\n  def foo(bar)\n  end\nend
    \n", "<<< ruby\nclass A\n def foo(bar)\n end\nend\n>>>") assert_convert("
    class A\n  def foo(bar)\n  end\nend
    \n", "<<< Ruby\nclass A\n def foo(bar)\n end\nend\n>>>") assert_convert("
    'a<\">b'
    \n", "<<< ruby\n'a<\">b'\n>>>") end def test_plugin_in_pre_with_header assert_convert("

    Title

    \n
    {{_/a:a}}
    \n", "! Title\n {{_/a:a}}") assert_convert("

    Title

    \n
    {{_/a:a}}\n{{_/a:a}}
    \n", "! Title\n {{_/a:a}}\n {{_/a:a}}") end private def assert_convert(expected, markup, options={}, message=nil) assert_equal(expected, HikiDoc.to_xhtml(markup, options), message) end def custom_valid_plugin_syntax?(code) eval("BEGIN {return true}\n#{code}", nil, "(plugin)", 0) rescue SyntaxError false end end