nora_mark 0.2beta3 → 0.2beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/README.md +17 -12
- data/example/nora-simple.css +52 -0
- data/example/noramark-reference-ja.nora +246 -0
- data/example/noramark-reference-ja_00001.xhtml +187 -0
- data/lib/nora_mark/html/{abstract_item_writer.rb → abstract_node_writer.rb} +3 -3
- data/lib/nora_mark/html/context.rb +3 -21
- data/lib/nora_mark/html/frontmatter_writer.rb +33 -0
- data/lib/nora_mark/html/generator.rb +122 -100
- data/lib/nora_mark/html/pages.rb +3 -9
- data/lib/nora_mark/html/paragraph_writer.rb +27 -23
- data/lib/nora_mark/html/tag_writer.rb +33 -34
- data/lib/nora_mark/html/writer_selector.rb +3 -3
- data/lib/nora_mark/node.rb +31 -0
- data/lib/nora_mark/parser.kpeg +133 -79
- data/lib/nora_mark/parser.kpeg.rb +1822 -1526
- data/lib/nora_mark/parser.rb +4 -23
- data/lib/nora_mark/version.rb +1 -1
- data/lib/nora_mark.rb +7 -2
- data/nora_mark.gemspec +1 -0
- data/spec/epub30-schemas/epub-nav-30.nvdl +16 -0
- data/spec/epub30-schemas/epub-nav-30.rnc +10 -0
- data/spec/epub30-schemas/epub-nav-30.sch +72 -0
- data/spec/epub30-schemas/epub-svg-30.nvdl +15 -0
- data/spec/epub30-schemas/epub-svg-30.rnc +15 -0
- data/spec/epub30-schemas/epub-svg-30.sch +10 -0
- data/spec/epub30-schemas/epub-xhtml-30.nvdl +15 -0
- data/spec/epub30-schemas/epub-xhtml-30.rnc +37 -0
- data/spec/epub30-schemas/epub-xhtml-30.sch +377 -0
- data/spec/epub30-schemas/epub30-catalog.xml +335 -0
- data/spec/epub30-schemas/media-overlay-30.nvdl +14 -0
- data/spec/epub30-schemas/media-overlay-30.rnc +46 -0
- data/spec/epub30-schemas/media-overlay-30.sch +9 -0
- data/spec/epub30-schemas/mod/datatypes.rnc +143 -0
- data/spec/epub30-schemas/mod/epub-mathml3-30.rnc +74 -0
- data/spec/epub30-schemas/mod/epub-prefix-attr.rnc +8 -0
- data/spec/epub30-schemas/mod/epub-ssml-attrs.rnc +11 -0
- data/spec/epub30-schemas/mod/epub-svg11-30.rnc +12 -0
- data/spec/epub30-schemas/mod/epub-svg11-re.sch +7 -0
- data/spec/epub30-schemas/mod/epub-switch.rnc +32 -0
- data/spec/epub30-schemas/mod/epub-trigger.rnc +17 -0
- data/spec/epub30-schemas/mod/epub-type-attr.rnc +7 -0
- data/spec/epub30-schemas/mod/epub-xhtml-mathml3-30.rnc +5 -0
- data/spec/epub30-schemas/mod/epub-xhtml-svg11-30.rnc +6 -0
- data/spec/epub30-schemas/mod/html5/LICENSE +23 -0
- data/spec/epub30-schemas/mod/html5/README +21 -0
- data/spec/epub30-schemas/mod/html5/html5-aria-30.rnc +105 -0
- data/spec/epub30-schemas/mod/html5/html5-attrib-30.rnc +44 -0
- data/spec/epub30-schemas/mod/html5/html5-document-30.rnc +44 -0
- data/spec/epub30-schemas/mod/html5/html5-edit-30.rnc +24 -0
- data/spec/epub30-schemas/mod/html5/html5-embed-30.rnc +155 -0
- data/spec/epub30-schemas/mod/html5/html5-forms-30.rnc +431 -0
- data/spec/epub30-schemas/mod/html5/html5-grouping-30.rnc +115 -0
- data/spec/epub30-schemas/mod/html5/html5-interactive-30.rnc +86 -0
- data/spec/epub30-schemas/mod/html5/html5-models-30.rnc +10 -0
- data/spec/epub30-schemas/mod/html5/html5-phrasing-30.rnc +134 -0
- data/spec/epub30-schemas/mod/html5/html5-script-30.rnc +164 -0
- data/spec/epub30-schemas/mod/html5/html5-sections-30.rnc +58 -0
- data/spec/epub30-schemas/mod/html5/html5-style-30.rnc +18 -0
- data/spec/epub30-schemas/mod/id-unique.sch +10 -0
- data/spec/epub30-schemas/mod/mathml/LICENSE +3 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-common.rnc +84 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-content.rnc +373 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-presentation.rnc +536 -0
- data/spec/epub30-schemas/mod/mathml/mathml3-strict-content.rnc +60 -0
- data/spec/epub30-schemas/mod/security/LICENSE +4 -0
- data/spec/epub30-schemas/mod/security/Lenient-Encryption11-ghc.rnc +41 -0
- data/spec/epub30-schemas/mod/security/Lenient-Encryption11.rnc +39 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature-exclusiveC14N.rnc +25 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties-exclusiveC14N.rnc +32 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11-properties.rnc +30 -0
- data/spec/epub30-schemas/mod/security/Lenient-Signature11.rnc +28 -0
- data/spec/epub30-schemas/mod/security/Strict-Encryption.rnc +27 -0
- data/spec/epub30-schemas/mod/security/Strict-Signature.rnc +22 -0
- data/spec/epub30-schemas/mod/security/exc-c14n.rnc +39 -0
- data/spec/epub30-schemas/mod/security/security_any.rnc +15 -0
- data/spec/epub30-schemas/mod/security/xenc-allowAnyForeign.rnc +25 -0
- data/spec/epub30-schemas/mod/security/xenc-schema-11.rnc +96 -0
- data/spec/epub30-schemas/mod/security/xenc-schema.rnc +145 -0
- data/spec/epub30-schemas/mod/security/xenc11-allowAnyForeign.rnc +19 -0
- data/spec/epub30-schemas/mod/security/xmldsig-allowAnyForeign.rnc +47 -0
- data/spec/epub30-schemas/mod/security/xmldsig-core-schema.rnc +276 -0
- data/spec/epub30-schemas/mod/security/xmldsig-filter2.rnc +16 -0
- data/spec/epub30-schemas/mod/security/xmldsig-properties-schema.rnc +34 -0
- data/spec/epub30-schemas/mod/security/xmldsig11-allowAnyForeign.rnc +18 -0
- data/spec/epub30-schemas/mod/security/xmldsig11-schema.rnc +133 -0
- data/spec/epub30-schemas/mod/security/xmlsec-ghc-allowAnyForeign.rnc +21 -0
- data/spec/epub30-schemas/mod/security/xmlsec-ghc-schema.rnc +42 -0
- data/spec/epub30-schemas/mod/svg11/LICENSE +1 -0
- data/spec/epub30-schemas/mod/svg11/README.txt +8 -0
- data/spec/epub30-schemas/mod/svg11/svg11-flat.rnc +3999 -0
- data/spec/epub30-schemas/ocf-container-30.rnc +16 -0
- data/spec/epub30-schemas/ocf-encryption-30.rnc +12 -0
- data/spec/epub30-schemas/ocf-signatures-30.rnc +8 -0
- data/spec/epub30-schemas/package-30.nvdl +14 -0
- data/spec/epub30-schemas/package-30.rnc +91 -0
- data/spec/epub30-schemas/package-30.sch +137 -0
- data/spec/jing-20091111/bin/jing.jar +0 -0
- data/spec/nora_mark_spec.rb +229 -68
- data/spec/spec_helper.rb +16 -0
- metadata +179 -6
- data/lib/nora_mark/html/header_writer.rb +0 -35
- data/spec/fixture/test_src_ja.nora +0 -50
data/lib/nora_mark/parser.kpeg
CHANGED
@@ -1,123 +1,177 @@
|
|
1
1
|
%% name = NoraMark::Parser
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
30
|
-
|
50
|
+
ImplicitParagraph = - !ParagraphDelimiter Comment* DocumentLine:content Comment* EofComment? ~paragraph([],[], [], content)
|
51
|
+
Paragraph = ExplicitParagraph | ImplicitParagraph
|
31
52
|
|
32
53
|
# paragraph_group
|
33
|
-
|
54
|
+
ParagraphGroup = Paragraph+:p EmptyLine* ~paragraph_group([],[],[],p)
|
34
55
|
|
35
56
|
# explicit block
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
85
|
+
CommandNameForSpecialLineCommand = NewpageCommand | ExplicitParagraphCommand
|
55
86
|
|
56
87
|
# newpage
|
57
|
-
|
58
|
-
|
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
|
-
|
62
|
-
|
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
|
-
|
67
|
-
|
97
|
+
UnorderedList = UnorderedItem+:items ~unordered_list([],[],[], items)
|
98
|
+
UnorderedItem = '*:' - DocumentContent:content Le ~ul_item([], [], [], content)
|
68
99
|
|
69
100
|
# ordered list
|
70
|
-
|
71
|
-
|
101
|
+
OrderedList = OrderedItem+:items ~ordered_list([],[],[], items)
|
102
|
+
OrderedItem = Num ':' - DocumentContent:content Le ~ol_item([], [], [], content)
|
72
103
|
|
73
104
|
# definition list
|
74
|
-
|
75
|
-
|
105
|
+
DefinitionList = DefinitionItem+:items ~definition_list([], [], [], items)
|
106
|
+
DefinitionItem = - ';:' - DocumentContentExcept(':'):term ':' - DocumentContent:definition Le ~dl_item([], [], [term], definition)
|
76
107
|
|
77
|
-
|
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
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
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 =
|
174
|
+
root = Page:page NewpagedPage*:pages - EofComment? Eof { [ page ] + pages }
|
121
175
|
|
122
176
|
|
123
177
|
|