nora_mark 0.2beta3 → 0.2beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -0
  3. data/Gemfile +2 -0
  4. data/README.md +17 -12
  5. data/example/nora-simple.css +52 -0
  6. data/example/noramark-reference-ja.nora +246 -0
  7. data/example/noramark-reference-ja_00001.xhtml +187 -0
  8. data/lib/nora_mark/html/{abstract_item_writer.rb → abstract_node_writer.rb} +3 -3
  9. data/lib/nora_mark/html/context.rb +3 -21
  10. data/lib/nora_mark/html/frontmatter_writer.rb +33 -0
  11. data/lib/nora_mark/html/generator.rb +122 -100
  12. data/lib/nora_mark/html/pages.rb +3 -9
  13. data/lib/nora_mark/html/paragraph_writer.rb +27 -23
  14. data/lib/nora_mark/html/tag_writer.rb +33 -34
  15. data/lib/nora_mark/html/writer_selector.rb +3 -3
  16. data/lib/nora_mark/node.rb +31 -0
  17. data/lib/nora_mark/parser.kpeg +133 -79
  18. data/lib/nora_mark/parser.kpeg.rb +1822 -1526
  19. data/lib/nora_mark/parser.rb +4 -23
  20. data/lib/nora_mark/version.rb +1 -1
  21. data/lib/nora_mark.rb +7 -2
  22. data/nora_mark.gemspec +1 -0
  23. data/spec/epub30-schemas/epub-nav-30.nvdl +16 -0
  24. data/spec/epub30-schemas/epub-nav-30.rnc +10 -0
  25. data/spec/epub30-schemas/epub-nav-30.sch +72 -0
  26. data/spec/epub30-schemas/epub-svg-30.nvdl +15 -0
  27. data/spec/epub30-schemas/epub-svg-30.rnc +15 -0
  28. data/spec/epub30-schemas/epub-svg-30.sch +10 -0
  29. data/spec/epub30-schemas/epub-xhtml-30.nvdl +15 -0
  30. data/spec/epub30-schemas/epub-xhtml-30.rnc +37 -0
  31. data/spec/epub30-schemas/epub-xhtml-30.sch +377 -0
  32. data/spec/epub30-schemas/epub30-catalog.xml +335 -0
  33. data/spec/epub30-schemas/media-overlay-30.nvdl +14 -0
  34. data/spec/epub30-schemas/media-overlay-30.rnc +46 -0
  35. data/spec/epub30-schemas/media-overlay-30.sch +9 -0
  36. data/spec/epub30-schemas/mod/datatypes.rnc +143 -0
  37. data/spec/epub30-schemas/mod/epub-mathml3-30.rnc +74 -0
  38. data/spec/epub30-schemas/mod/epub-prefix-attr.rnc +8 -0
  39. data/spec/epub30-schemas/mod/epub-ssml-attrs.rnc +11 -0
  40. data/spec/epub30-schemas/mod/epub-svg11-30.rnc +12 -0
  41. data/spec/epub30-schemas/mod/epub-svg11-re.sch +7 -0
  42. data/spec/epub30-schemas/mod/epub-switch.rnc +32 -0
  43. data/spec/epub30-schemas/mod/epub-trigger.rnc +17 -0
  44. data/spec/epub30-schemas/mod/epub-type-attr.rnc +7 -0
  45. data/spec/epub30-schemas/mod/epub-xhtml-mathml3-30.rnc +5 -0
  46. data/spec/epub30-schemas/mod/epub-xhtml-svg11-30.rnc +6 -0
  47. data/spec/epub30-schemas/mod/html5/LICENSE +23 -0
  48. data/spec/epub30-schemas/mod/html5/README +21 -0
  49. data/spec/epub30-schemas/mod/html5/html5-aria-30.rnc +105 -0
  50. data/spec/epub30-schemas/mod/html5/html5-attrib-30.rnc +44 -0
  51. data/spec/epub30-schemas/mod/html5/html5-document-30.rnc +44 -0
  52. data/spec/epub30-schemas/mod/html5/html5-edit-30.rnc +24 -0
  53. data/spec/epub30-schemas/mod/html5/html5-embed-30.rnc +155 -0
  54. data/spec/epub30-schemas/mod/html5/html5-forms-30.rnc +431 -0
  55. data/spec/epub30-schemas/mod/html5/html5-grouping-30.rnc +115 -0
  56. data/spec/epub30-schemas/mod/html5/html5-interactive-30.rnc +86 -0
  57. data/spec/epub30-schemas/mod/html5/html5-models-30.rnc +10 -0
  58. data/spec/epub30-schemas/mod/html5/html5-phrasing-30.rnc +134 -0
  59. data/spec/epub30-schemas/mod/html5/html5-script-30.rnc +164 -0
  60. data/spec/epub30-schemas/mod/html5/html5-sections-30.rnc +58 -0
  61. data/spec/epub30-schemas/mod/html5/html5-style-30.rnc +18 -0
  62. data/spec/epub30-schemas/mod/id-unique.sch +10 -0
  63. data/spec/epub30-schemas/mod/mathml/LICENSE +3 -0
  64. data/spec/epub30-schemas/mod/mathml/mathml3-common.rnc +84 -0
  65. data/spec/epub30-schemas/mod/mathml/mathml3-content.rnc +373 -0
  66. data/spec/epub30-schemas/mod/mathml/mathml3-presentation.rnc +536 -0
  67. data/spec/epub30-schemas/mod/mathml/mathml3-strict-content.rnc +60 -0
  68. data/spec/epub30-schemas/mod/security/LICENSE +4 -0
  69. data/spec/epub30-schemas/mod/security/Lenient-Encryption11-ghc.rnc +41 -0
  70. data/spec/epub30-schemas/mod/security/Lenient-Encryption11.rnc +39 -0
  71. data/spec/epub30-schemas/mod/security/Lenient-Signature-exclusiveC14N.rnc +25 -0
  72. data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties-exclusiveC14N.rnc +32 -0
  73. data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties.rnc +30 -0
  74. data/spec/epub30-schemas/mod/security/Lenient-Signature11.rnc +28 -0
  75. data/spec/epub30-schemas/mod/security/Strict-Encryption.rnc +27 -0
  76. data/spec/epub30-schemas/mod/security/Strict-Signature.rnc +22 -0
  77. data/spec/epub30-schemas/mod/security/exc-c14n.rnc +39 -0
  78. data/spec/epub30-schemas/mod/security/security_any.rnc +15 -0
  79. data/spec/epub30-schemas/mod/security/xenc-allowAnyForeign.rnc +25 -0
  80. data/spec/epub30-schemas/mod/security/xenc-schema-11.rnc +96 -0
  81. data/spec/epub30-schemas/mod/security/xenc-schema.rnc +145 -0
  82. data/spec/epub30-schemas/mod/security/xenc11-allowAnyForeign.rnc +19 -0
  83. data/spec/epub30-schemas/mod/security/xmldsig-allowAnyForeign.rnc +47 -0
  84. data/spec/epub30-schemas/mod/security/xmldsig-core-schema.rnc +276 -0
  85. data/spec/epub30-schemas/mod/security/xmldsig-filter2.rnc +16 -0
  86. data/spec/epub30-schemas/mod/security/xmldsig-properties-schema.rnc +34 -0
  87. data/spec/epub30-schemas/mod/security/xmldsig11-allowAnyForeign.rnc +18 -0
  88. data/spec/epub30-schemas/mod/security/xmldsig11-schema.rnc +133 -0
  89. data/spec/epub30-schemas/mod/security/xmlsec-ghc-allowAnyForeign.rnc +21 -0
  90. data/spec/epub30-schemas/mod/security/xmlsec-ghc-schema.rnc +42 -0
  91. data/spec/epub30-schemas/mod/svg11/LICENSE +1 -0
  92. data/spec/epub30-schemas/mod/svg11/README.txt +8 -0
  93. data/spec/epub30-schemas/mod/svg11/svg11-flat.rnc +3999 -0
  94. data/spec/epub30-schemas/ocf-container-30.rnc +16 -0
  95. data/spec/epub30-schemas/ocf-encryption-30.rnc +12 -0
  96. data/spec/epub30-schemas/ocf-signatures-30.rnc +8 -0
  97. data/spec/epub30-schemas/package-30.nvdl +14 -0
  98. data/spec/epub30-schemas/package-30.rnc +91 -0
  99. data/spec/epub30-schemas/package-30.sch +137 -0
  100. data/spec/jing-20091111/bin/jing.jar +0 -0
  101. data/spec/nora_mark_spec.rb +229 -68
  102. data/spec/spec_helper.rb +16 -0
  103. metadata +179 -6
  104. data/lib/nora_mark/html/header_writer.rb +0 -35
  105. data/spec/fixture/test_src_ja.nora +0 -50
@@ -1,123 +1,177 @@
1
1
  %% name = NoraMark::Parser
2
2
 
3
- # literals
4
- eof = !.
5
- space = ' ' | '\t'
6
- eof_comment = lh space* "#" (!eof .)*
7
- comment = lh space* "#" (!nl .)* nl empty_line*
8
- - = ( space | comment )*
9
- empty_line = lh - nl
10
- nl = /\r?\n/
11
- lh = /^/
12
- le = nl | eof
13
- word = < /[\w0-9]/ ( '-' | /[\w0-9]/ )* > { text }
14
- num = < [0-9]+ > { text.to_i }
3
+ %% ast-location = ::NoraMark
4
+ %% text = ast Text(content)
5
+ %% paragraph = ast Paragraph(ids, classes, parameters, content)
6
+ %% paragraph_group = ast ParagraphGroup(ids, classes, parameters, content)
7
+ %% br = ast Breakline()
8
+ %% line_command = ast LineCommand(name, ids, classes, parameters, content)
9
+ %% block = ast Block(name, ids, classes, parameters, content)
10
+ %% newpage = ast Newpage(ids, classes, parameters, content)
11
+ %% inline = ast Inline(name, ids, classes, parameters, content)
12
+ %% ul_item = ast UlItem(ids, classes, parameters, content)
13
+ %% unordered_list = ast UnorderedList(ids, classes, parameters, content)
14
+ %% ol_item = ast OlItem(ids, classes, parameters, content)
15
+ %% ordered_list = ast OrderedList(ids, classes, parameters, content)
16
+ %% dl_item = ast DLItem(ids, classes, parameters, content)
17
+ %% definition_list = ast DefinitionList(ids, classes, parameters, content)
18
+ %% preformatted_block = ast PreformattedBlock(name, ids, classes, parameters, codelanguage, content)
19
+ %% frontmatter = ast Frontmatter(content)
20
+ %% h_section = ast HeadedSection(level, heading, content)
21
+ %% page = ast Page(content)
15
22
 
23
+ # literals
24
+ Eof = !.
25
+ Space = ' ' | '\t'
26
+ EofComment = Space* "#" (!Eof .)*
27
+ Comment = Space* "#" (!Nl .)* Nl EmptyLine*
28
+ - = ( Space )*
29
+ EmptyLine = /^/ - (Nl | Comment | EofComment)
30
+ Nl = /\r?\n/
31
+ Le = Nl | Eof
32
+ Word = < /[\w0-9]/ ( '-' | /[\w0-9]/ )* > { text }
33
+ Num = < [0-9]+ > { text.to_i }
16
34
 
17
35
  #common syntax
18
- classname = '.' word:classname { classname }
19
- classnames = (classname)*:classnames { classnames }
20
- idname = '#' word:idname { idname }
21
- idnames = (idname)*:idnames { idnames }
22
-
23
- commandname = word:name idnames?:idnames classnames?:classes { {:name => name, :ids => idnames, :classes => classes} }
24
- parameter = < ( /[^,)]/* | '"' /[^"]/* '"' | "'" /[^']/* "'" ) > { text }
25
- parameters = < parameter (',' parameter)* > { text }
26
- command = commandname:cn ('(' - parameters:arg - ')')? { arg ||= ''; cn.merge({ :args => arg.split(',') }) }
36
+ ClassName = '.' Word:classname { classname }
37
+ ClassNames = (ClassName)*:classnames { classnames }
38
+ IdName = '#' Word:idname { idname }
39
+ IdNames = (IdName)*:idnames { idnames }
40
+
41
+ CommandName = Word:name IdNames?:idnames ClassNames?:classes { {name: name, ids: idnames, classes: classes} }
42
+ ParameterNormal = < /[^,)]/* > { text }
43
+ ParameterQuoted = '"' < /[^"]/* > '"' - &/[,)]/ { text }
44
+ ParameterSingleQuoted = "'" < /[^']/* > "'" - &/[,)]/ { text }
45
+ Parameter = (ParameterQuoted | ParameterSingleQuoted | ParameterNormal ):value { value }
46
+ Parameters = Parameter:parameter (',' - Parameter)*:rest_parameters { [parameter] + rest_parameters }
47
+ Command = CommandName:cn ('(' - Parameters:args - ')')? { args ||= []; cn.merge({ args: args }) }
27
48
 
28
49
  # paragraph
29
- implicit_paragraph = < (!paragraph_delimiter - documentline:p -) > { create_item(:paragraph, nil, p, raw: text) }
30
- paragraph = explicit_paragraph | implicit_paragraph
50
+ ImplicitParagraph = - !ParagraphDelimiter Comment* DocumentLine:content Comment* EofComment? ~paragraph([],[], [], content)
51
+ Paragraph = ExplicitParagraph | ImplicitParagraph
31
52
 
32
53
  # paragraph_group
33
- paragraph_group = < paragraph+:p empty_line* > { create_item(:paragraph_group, nil, p, raw: text) }
54
+ ParagraphGroup = Paragraph+:p EmptyLine* ~paragraph_group([],[],[],p)
34
55
 
35
56
  # explicit block
36
- blockhead = lh - command:command - '{' - nl empty_line* { command }
37
- blockend = lh - '}' - le empty_line*
38
- blockbody = (!blockend block)+:body { body }
39
- explicit_block = < blockhead:head - blockbody:body - blockend > { create_item(:block, head, body, raw: text) }
57
+ BlockHead = - Command:command - '{' - Nl EmptyLine* { command }
58
+ BlockEnd = - '}' - Le EmptyLine*
59
+ BlockBody = (!BlockEnd Block)+:body { body }
60
+ ExplicitBlock = BlockHead:c - BlockBody:content - BlockEnd ~block(c[:name], c[:ids], c[:classes], c[:args], content)
40
61
 
41
62
  # preformatted block
42
- preformatted_command = command:command &{ ['pre', 'precode'].include? command[:name] }
43
- preformatted_command_head = lh - preformatted_command:command - '<<' &/[\w0-9]/ { command }
44
- preformat_end(start) = lh word:delimiter &{ delimiter == start }
45
- preformatted_block = < lh - preformatted_command_head:command !nl word:delimiter nl (!preformat_end(delimiter) (lh charstring nl))+:content preformat_end(delimiter) > { create_item(:preformatted, command, content, raw: text) }
63
+ PreformattedCommand = Command:command &{ ['pre', 'code'].include? command[:name] }
64
+ PreformattedCommandHeadSimple = - PreformattedCommand:command - '{' - Nl { command }
65
+ PreformattedCommandHeadComplex = - PreformattedCommand:command - '{//' Word?:codelanguage - Nl { command.merge({codelanguage: codelanguage}) }
66
+ PreformattedCommandHead = PreformattedCommandHeadComplex | PreformattedCommandHeadSimple
67
+ PreformatEndSimple = - '}' - Le EmptyLine*
68
+ PreformatEndComplex = - '//}' - Le EmptyLine*
69
+
70
+ PreformattedBlockSimple = PreformattedCommandHeadSimple:c (!PreformatEndSimple (CharString Nl))+:content PreformatEndSimple
71
+ ~preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)
72
+
73
+ PreformattedBlockComplex = PreformattedCommandHeadComplex:c (!PreformatEndComplex (CharString Nl))+:content PreformatEndComplex
74
+ ~preformatted_block(c[:name], c[:ids], c[:classes], c[:args], c[:codelanguage], content)
75
+
76
+ PreformattedBlock = PreformattedBlockComplex | PreformattedBlockSimple
46
77
 
47
78
  # inline command
48
- inline = img_inline | common_inline
49
- common_inline = < '[' command:c '{' documentcontent_except('}'):content '}' ']' > { create_item(:inline, c, content, raw: text) }
50
- img_command = command:c &{ c[:name] == 'img' && c[:args].size == 2}
51
- img_inline = < '[' img_command:c ']' > { create_item(:inline, c, nil, raw: text) }
79
+ Inline = ImgInline | CommonInline
80
+ CommonInline = '[' Command:c '{' - DocumentContentExcept('}'):content '}' ']' ~inline(c[:name], c[:ids], c[:classes], c[:args], content)
81
+ ImgCommand = Command:c &{ c[:name] == 'img' && c[:args].size == 2}
82
+ ImgInline = '[' ImgCommand:c ']' ~inline(c[:name], c[:ids], c[:classes], c[:args], nil)
52
83
 
53
84
  # special line commands
54
- commandname_for_special_line_command = newpage_command | explicit_paragraph_command
85
+ CommandNameForSpecialLineCommand = NewpageCommand | ExplicitParagraphCommand
55
86
 
56
87
  # newpage
57
- newpage_command = command:command &{ command[:name] == 'newpage' }
58
- newpage = < lh - newpage_command:c ':' documentcontent?:content - nl > { create_item(:newpage, c, content, raw:text) }
88
+ NewpageCommand = Command:command &{ command[:name] == 'newpage' }
89
+ Newpage = - NewpageCommand:c ':' - DocumentContent?:content - Nl ~newpage(c[:ids],c[:classes],c[:args], content)
59
90
 
60
91
  # explicit paragraph
61
- explicit_paragraph_command = command:c &{ c[:name] == 'p' }
62
- explicit_paragraph = < lh - explicit_paragraph_command:c ':' documentcontent?:content le empty_line*> { create_item(:paragraph, c, content, raw:text) }
92
+ ExplicitParagraphCommand = Command:c &{ c[:name] == 'p' }
93
+ ExplicitParagraph = - ExplicitParagraphCommand:c ':' - DocumentContent?:content Le EmptyLine* ~paragraph(c[:ids], c[:classes], c[:args], content)
63
94
 
64
95
 
65
96
  # unordered list
66
- unordered_list = < unordered_item+:items > { create_item(:ul, nil, items, raw: text) }
67
- unordered_item = < lh '*:' documentcontent:content le > { create_item(:li, nil, content, raw: text) }
97
+ UnorderedList = UnorderedItem+:items ~unordered_list([],[],[], items)
98
+ UnorderedItem = '*:' - DocumentContent:content Le ~ul_item([], [], [], content)
68
99
 
69
100
  # ordered list
70
- ordered_list = < ordered_item+:items > { create_item(:ol, nil, items, raw: text) }
71
- ordered_item = < lh num ':' documentcontent:content le > { create_item(:li, nil, content, raw: text) }
101
+ OrderedList = OrderedItem+:items ~ordered_list([],[],[], items)
102
+ OrderedItem = Num ':' - DocumentContent:content Le ~ol_item([], [], [], content)
72
103
 
73
104
  # definition list
74
- definition_list = < definition_item+:items > { create_item(:dl, nil, items, raw: text) }
75
- definition_item = < lh ';:' - documentcontent_except(':'):term ':' - documentcontent:definition le > { create_item(:dtdd, {:args => [term, definition]}, nil, raw: text) }
105
+ DefinitionList = DefinitionItem+:items ~definition_list([], [], [], items)
106
+ DefinitionItem = - ';:' - DocumentContentExcept(':'):term ':' - DocumentContent:definition Le ~dl_item([], [], [term], definition)
76
107
 
77
- items_list = unordered_list | ordered_list | definition_list
108
+ # long definition list
109
+ LongDefinitionList = LongDefinitionItem+:items ~definition_list([], [], [], items)
110
+ LongDefinitionItem = - ';:' - DocumentContentExcept('{'):term '{' - Nl - BlockBody:definition - BlockEnd ~dl_item([], [], [term], definition)
111
+
112
+ ItemsList = UnorderedList
113
+ | OrderedList
114
+ | DefinitionList
115
+ | LongDefinitionList
78
116
 
79
117
 
80
118
  # generic line command
81
- line_command = < lh - !commandname_for_special_line_command command:c ':' documentcontent?:content - le empty_line* > { create_item(:line_command, c, content, raw: text) }
119
+ LineCommand = - !CommandNameForSpecialLineCommand Command:c ':' - DocumentContent?:content - Le EmptyLine* ~line_command(c[:name], c[:ids], c[:classes], c[:args], content)
82
120
 
83
121
  # blocks
84
- line_block = items_list | line_command
85
- block = (preformatted_block | headed_section | line_block | explicit_block | paragraph_group ):block empty_line* {block}
86
- block_delimiter = blockhead | blockend
87
- paragraph_delimiter = block_delimiter | preformatted_command_head | line_block | newpage | headed_start
122
+ LineBlock = ItemsList | LineCommand
123
+ Block = EmptyLine*
124
+ (PreformattedBlock
125
+ | HeadedSection
126
+ | LineBlock
127
+ | ExplicitBlock
128
+ | ParagraphGroup ):block
129
+ EmptyLine* {block}
130
+
131
+ BlockDelimiter = BlockHead | BlockEnd
132
+ ParagraphDelimiter = BlockDelimiter | PreformattedCommandHead | LineBlock | Newpage | HeadedStart
88
133
 
89
134
  # markdown-style headings
90
- h_start_mark(n) = < '='+ ':' > &{ text.length - 1 == n }
91
- h_markup_terminator(n) = lh - < '='+ ':' > &{ text.length - 1 <= n }
92
-
93
- h_start(n) = lh - h_start_mark(n) charstring:s le { { level: n, heading: s } }
94
- h_section(n) = < h_start(n):h (!h_markup_terminator(n) !eof block)+:content > { create_item(:h_section, h, content, raw: text) }
95
-
96
- headed_start = h_start(1) | h_start(2) | h_start(3) | h_start(4) | h_start(5) | h_start(6)
97
- headed_section = h_section(1) | h_section(2)| h_section(3)| h_section(4)| h_section(5) | h_section(6)
98
-
99
- #header
100
- stylesheets = < lh - 'stylesheets:' !le charstring:s nl > { create_item(:stylesheets, {:stylesheets => s.split(',').map(&:strip)}, nil, raw:text) }
101
- title = < lh - 'title:' !le charstring:t nl > { create_item(:title, {:title => t }, nil, raw:text) }
102
- lang = < lh - 'lang:' !le charstring:l nl > { create_item(:lang, {:lang => l }, nil, raw:text) }
103
- paragraph_style = < lh - 'paragraph-style:' !le charstring:l nl > { create_item(:paragraph_style, {:paragraph_style => l }, nil, raw:text) }
104
- header = (stylesheets | title | lang | paragraph_style ) empty_line*
135
+ HStartMark(n) = < '='+ ':' > &{ text.length - 1 == n }
136
+ HMarkupTerminator(n) = - < '='+ ':' > &{ text.length - 1 <= n }
137
+
138
+ HStart(n) = - HStartMark(n) - DocumentContent:s Le { { level: n, heading: s } }
139
+ HSection(n) = HStart(n):h (!HMarkupTerminator(n) !Eof Block)*:content ~h_section(h[:level], h[:heading], content)
140
+
141
+ HeadedStart = HStart(1)
142
+ | HStart(2)
143
+ | HStart(3)
144
+ | HStart(4)
145
+ | HStart(5)
146
+ | HStart(6)
147
+
148
+ HeadedSection = HSection(1)
149
+ | HSection(2)
150
+ | HSection(3)
151
+ | HSection(4)
152
+ | HSection(5)
153
+ | HSection(6)
154
+
155
+ # frontmatter
156
+ FrontmatterSeparator = - '---' - Nl
157
+ Frontmatter = FrontmatterSeparator (!FrontmatterSeparator ( CharString Nl))+:yaml FrontmatterSeparator EmptyLine* ~frontmatter(yaml)
105
158
 
106
159
  # texts
107
- char = < /[[:print:]]/ > { text }
108
- charstring = < char* > { text }
109
- char_except(e) = char:c &{ c != e }
110
- charstring_except(e) = < char_except(e)* > { text }
111
- documentcontent_except(e) = (inline | !inline char_except(e))+:content ~parse_text(content)
112
- documentcontent = (inline | !inline char)+:content ~parse_text(content)
113
- documentline = lh documentcontent:content le { content }
160
+ Char = < /[[:print:]]/ > { text }
161
+ CharString = < Char* > { text }
162
+ CharExcept(e) = Char:c &{ c != e }
163
+ DocumentTextExcept(e) = < (!Inline CharExcept(e))+ > ~text(text)
164
+ DocumentContentExcept(e) = (Inline | DocumentTextExcept(e))+:content { content }
165
+ DocumentText = < (!Inline Char)+ > ~text(text)
166
+ DocumentContent = (Inline | DocumentText)+:content { content }
167
+ DocumentLine = DocumentContent:content Le { content }
114
168
 
115
169
  #page
116
- headers = header*:headers { create_item(:headers, nil, headers) }
117
- page = headers:headers - (!newpage block)*:blocks { create_item(:page, nil, [headers] + blocks.select{ |x| !x.nil?}) }
118
- newpaged_page = newpage:newpage page:page { page[:children] = page[:children].unshift newpage; page }
170
+ Page = Frontmatter?:frontmatter - (!Newpage Block)*:blocks ~page(([frontmatter] + blocks).select{ |x| !x.nil?})
171
+ NewpagedPage = Newpage:newpage Page:page { page.content = page.content.unshift newpage; page }
172
+
119
173
  #root
120
- root = page:page newpaged_page*:pages - eof_comment? eof { [ page ] + pages }
174
+ root = Page:page NewpagedPage*:pages - EofComment? Eof { [ page ] + pages }
121
175
 
122
176
 
123
177