From: Didier 'Ptitjes Date: Sat, 31 Oct 2009 12:33:01 +0000 (+0100) Subject: Parser: Make {{{ source code }}} acceptable inline X-Git-Tag: 0.37.1~3^2~499 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f277141d208ff5b3ba8ba209cb46d81d0449754;p=thirdparty%2Fvala.git Parser: Make {{{ source code }}} acceptable inline --- diff --git a/src/libvaladoc/content/sourcecode.vala b/src/libvaladoc/content/sourcecode.vala index f0ff3edf5..1841413a0 100755 --- a/src/libvaladoc/content/sourcecode.vala +++ b/src/libvaladoc/content/sourcecode.vala @@ -22,8 +22,7 @@ using Gee; - -public class Valadoc.Content.SourceCode : ContentElement, Block { +public class Valadoc.Content.SourceCode : ContentElement, Inline { public enum Language { GENIE, VALA, diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala index 48e92146b..7da33e6b2 100644 --- a/src/libvaladoc/documentation/documentationparser.vala +++ b/src/libvaladoc/documentation/documentationparser.vala @@ -329,10 +329,19 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { .set_name ("Link") .set_start (() => { push (_factory.create_link ()); }); + Rule source_code = + Rule.seq ({ + TokenType.TRIPLE_OPEN_BRACE.action ((token) => { _scanner.set_code_escape_mode (true); }), + TokenType.any_word ().action ((token) => { ((SourceCode) peek ()).code = token.to_string (); }), + TokenType.TRIPLE_CLOSED_BRACE.action ((token) => { _scanner.set_code_escape_mode (false); }) + }) + .set_name ("SourceCode") + .set_start (() => { push (_factory.create_source_code ()); }); + run.set_rule ( Rule.many ({ Rule.one_of ({ - text, inline_taglet, bold, italic, underlined, monospace, embedded, link + text, inline_taglet, bold, italic, underlined, monospace, embedded, link, source_code }) .set_reduce (() => { ((InlineContent) peek ()).content.add ((Inline) pop ()); }), Rule.option ({ space }) @@ -360,17 +369,6 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { .set_start (() => { push (_factory.create_paragraph ()); }) .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); }); - Rule source_code = - Rule.seq ({ - TokenType.TRIPLE_OPEN_BRACE.action ((token) => { _scanner.set_code_escape_mode (true); }), - TokenType.any_word ().action ((token) => { ((SourceCode) peek ()).code = token.to_string (); }), - TokenType.TRIPLE_CLOSED_BRACE.action ((token) => { _scanner.set_code_escape_mode (false); }), - TokenType.EOL - }) - .set_name ("SourceCode") - .set_start (() => { push (_factory.create_source_code ()); }) - .set_reduce (() => { ((BlockContent) peek ()).content.add ((Block) pop ()); }); - Rule indented_item = Rule.seq ({ Rule.many ({ @@ -516,7 +514,6 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator { Rule blocks = Rule.one_of ({ - source_code, indented_blocks, table, headline,