Bayeux 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. data/.hgrc +2 -0
  2. data/.rvmrc +27 -0
  3. data/Gemfile +42 -0
  4. data/Gemfile.lock +42 -0
  5. data/HISTORY +63 -0
  6. data/README.rdoc +19 -0
  7. data/Rakefile +89 -0
  8. data/VERSION +1 -0
  9. data/bib/Modules.bib +21 -0
  10. data/code/render/latex/active4d.render +132 -0
  11. data/code/render/latex/all_hallows_eve.render +96 -0
  12. data/code/render/latex/amy.render +171 -0
  13. data/code/render/latex/blackboard.render +111 -0
  14. data/code/render/latex/brilliance_black.render +552 -0
  15. data/code/render/latex/brilliance_dull.render +561 -0
  16. data/code/render/latex/cobalt.render +162 -0
  17. data/code/render/latex/dawn.render +126 -0
  18. data/code/render/latex/eiffel.render +132 -0
  19. data/code/render/latex/espresso_libre.render +123 -0
  20. data/code/render/latex/idle.render +93 -0
  21. data/code/render/latex/iplastic.render +99 -0
  22. data/code/render/latex/lazy.render +96 -0
  23. data/code/render/latex/mac_classic.render +135 -0
  24. data/code/render/latex/magicwb_amiga.render +117 -0
  25. data/code/render/latex/pastels_on_dark.render +204 -0
  26. data/code/render/latex/slush_poppies.render +123 -0
  27. data/code/render/latex/spacecadet.render +81 -0
  28. data/code/render/latex/sunburst.render +186 -0
  29. data/code/render/latex/twilight.render +153 -0
  30. data/code/render/latex/zenburnesque.render +126 -0
  31. data/code/render/old/txt2tags.render +131 -0
  32. data/code/render/xhtml/active4d.render +140 -0
  33. data/code/render/xhtml/all_hallows_eve.render +104 -0
  34. data/code/render/xhtml/amy.render +179 -0
  35. data/code/render/xhtml/blackboard.render +119 -0
  36. data/code/render/xhtml/brilliance_black.render +560 -0
  37. data/code/render/xhtml/brilliance_dull.render +569 -0
  38. data/code/render/xhtml/cobalt.render +170 -0
  39. data/code/render/xhtml/dawn.render +134 -0
  40. data/code/render/xhtml/eiffel.render +140 -0
  41. data/code/render/xhtml/espresso_libre.render +131 -0
  42. data/code/render/xhtml/files/css/active4d.css +114 -0
  43. data/code/render/xhtml/files/css/all_hallows_eve.css +72 -0
  44. data/code/render/xhtml/files/css/amy.css +147 -0
  45. data/code/render/xhtml/files/css/blackboard.css +88 -0
  46. data/code/render/xhtml/files/css/brilliance_black.css +605 -0
  47. data/code/render/xhtml/files/css/brilliance_dull.css +599 -0
  48. data/code/render/xhtml/files/css/cobalt.css +149 -0
  49. data/code/render/xhtml/files/css/dawn.css +121 -0
  50. data/code/render/xhtml/files/css/eiffel.css +121 -0
  51. data/code/render/xhtml/files/css/espresso_libre.css +109 -0
  52. data/code/render/xhtml/files/css/idle.css +62 -0
  53. data/code/render/xhtml/files/css/iplastic.css +80 -0
  54. data/code/render/xhtml/files/css/lazy.css +73 -0
  55. data/code/render/xhtml/files/css/mac_classic.css +123 -0
  56. data/code/render/xhtml/files/css/magicwb_amiga.css +104 -0
  57. data/code/render/xhtml/files/css/pastels_on_dark.css +188 -0
  58. data/code/render/xhtml/files/css/slush_poppies.css +85 -0
  59. data/code/render/xhtml/files/css/spacecadet.css +51 -0
  60. data/code/render/xhtml/files/css/sunburst.css +180 -0
  61. data/code/render/xhtml/files/css/twilight.css +137 -0
  62. data/code/render/xhtml/files/css/zenburnesque.css +91 -0
  63. data/code/render/xhtml/idle.render +101 -0
  64. data/code/render/xhtml/iplastic.render +107 -0
  65. data/code/render/xhtml/lazy.render +104 -0
  66. data/code/render/xhtml/mac_classic.render +143 -0
  67. data/code/render/xhtml/magicwb_amiga.render +125 -0
  68. data/code/render/xhtml/pastels_on_dark.render +212 -0
  69. data/code/render/xhtml/slush_poppies.render +131 -0
  70. data/code/render/xhtml/spacecadet.render +89 -0
  71. data/code/render/xhtml/sunburst.render +194 -0
  72. data/code/render/xhtml/twilight.render +161 -0
  73. data/code/render/xhtml/zenburnesque.render +134 -0
  74. data/code/syntax/actionscript.syntax +97 -0
  75. data/code/syntax/active4d.syntax +276 -0
  76. data/code/syntax/active4d_html.syntax +311 -0
  77. data/code/syntax/active4d_ini.syntax +50 -0
  78. data/code/syntax/active4d_library.syntax +21 -0
  79. data/code/syntax/ada.syntax +33 -0
  80. data/code/syntax/antlr.syntax +151 -0
  81. data/code/syntax/apache.syntax +191 -0
  82. data/code/syntax/applescript.syntax +384 -0
  83. data/code/syntax/asp.syntax +70 -0
  84. data/code/syntax/asp_vb.net.syntax +129 -0
  85. data/code/syntax/bibtex.syntax +151 -0
  86. data/code/syntax/blog_html.syntax +41 -0
  87. data/code/syntax/blog_markdown.syntax +42 -0
  88. data/code/syntax/blog_text.syntax +27 -0
  89. data/code/syntax/blog_textile.syntax +27 -0
  90. data/code/syntax/build.syntax +53 -0
  91. data/code/syntax/bulletin_board.syntax +287 -0
  92. data/code/syntax/cake.syntax +55 -0
  93. data/code/syntax/camlp4.syntax +36 -0
  94. data/code/syntax/cm.syntax +32 -0
  95. data/code/syntax/coldfusion.syntax +119 -0
  96. data/code/syntax/context_free.syntax +176 -0
  97. data/code/syntax/cs.syntax +59 -0
  98. data/code/syntax/css.syntax +195 -0
  99. data/code/syntax/css_experimental.syntax +1925 -0
  100. data/code/syntax/csv.syntax +68 -0
  101. data/code/syntax/d.syntax +142 -0
  102. data/code/syntax/diff.syntax +81 -0
  103. data/code/syntax/dokuwiki.syntax +204 -0
  104. data/code/syntax/dot.syntax +47 -0
  105. data/code/syntax/doxygen.syntax +43 -0
  106. data/code/syntax/dylan.syntax +62 -0
  107. data/code/syntax/eiffel.syntax +78 -0
  108. data/code/syntax/erlang.syntax +922 -0
  109. data/code/syntax/f-script.syntax +80 -0
  110. data/code/syntax/fortran.syntax +141 -0
  111. data/code/syntax/fxscript.syntax +142 -0
  112. data/code/syntax/greasemonkey.syntax +34 -0
  113. data/code/syntax/gri.syntax +83 -0
  114. data/code/syntax/groovy.syntax +191 -0
  115. data/code/syntax/gtd.syntax +22 -0
  116. data/code/syntax/gtdalt.syntax +143 -0
  117. data/code/syntax/haml.syntax +88 -0
  118. data/code/syntax/haskell.syntax +88 -0
  119. data/code/syntax/html-asp.syntax +27 -0
  120. data/code/syntax/html.syntax +362 -0
  121. data/code/syntax/html_django.syntax +36 -0
  122. data/code/syntax/html_for_asp.net.syntax +424 -0
  123. data/code/syntax/html_mason.syntax +119 -0
  124. data/code/syntax/html_rails.syntax +40 -0
  125. data/code/syntax/html_tcl.syntax +26 -0
  126. data/code/syntax/icalendar.syntax +32 -0
  127. data/code/syntax/inform.syntax +48 -0
  128. data/code/syntax/ini.syntax +55 -0
  129. data/code/syntax/installer_distribution_script.syntax +77 -0
  130. data/code/syntax/io.syntax +81 -0
  131. data/code/syntax/java.syntax +211 -0
  132. data/code/syntax/javaproperties.syntax +20 -0
  133. data/code/syntax/javascript.syntax +256 -0
  134. data/code/syntax/javascript_+_prototype.syntax +72 -0
  135. data/code/syntax/javascript_+_prototype_bracketed.syntax +140 -0
  136. data/code/syntax/jquery_javascript.syntax +114 -0
  137. data/code/syntax/json.syntax +136 -0
  138. data/code/syntax/languagedefinition.syntax +708 -0
  139. data/code/syntax/latex.syntax +566 -0
  140. data/code/syntax/latex_beamer.syntax +41 -0
  141. data/code/syntax/latex_log.syntax +50 -0
  142. data/code/syntax/latex_memoir.syntax +64 -0
  143. data/code/syntax/lexflex.syntax +219 -0
  144. data/code/syntax/lighttpd.syntax +54 -0
  145. data/code/syntax/lilypond.syntax +492 -0
  146. data/code/syntax/lisp.syntax +61 -0
  147. data/code/syntax/literate_haskell.syntax +24 -0
  148. data/code/syntax/logo.syntax +29 -0
  149. data/code/syntax/logtalk.syntax +152 -0
  150. data/code/syntax/lua.syntax +86 -0
  151. data/code/syntax/m.syntax +142 -0
  152. data/code/syntax/macports_portfile.syntax +163 -0
  153. data/code/syntax/makefile.syntax +36 -0
  154. data/code/syntax/man.syntax +17 -0
  155. data/code/syntax/mediawiki.syntax +567 -0
  156. data/code/syntax/mips.syntax +66 -0
  157. data/code/syntax/mod_perl.syntax +50 -0
  158. data/code/syntax/modula-3.syntax +47 -0
  159. data/code/syntax/moinmoin.syntax +189 -0
  160. data/code/syntax/mootools.syntax +572 -0
  161. data/code/syntax/movable_type.syntax +162 -0
  162. data/code/syntax/multimarkdown.syntax +39 -0
  163. data/code/syntax/objective-c++.syntax +18 -0
  164. data/code/syntax/objective-c.syntax +233 -0
  165. data/code/syntax/ocaml.syntax +764 -0
  166. data/code/syntax/ocamllex.syntax +167 -0
  167. data/code/syntax/ocamlyacc.syntax +184 -0
  168. data/code/syntax/opengl.syntax +14 -0
  169. data/code/syntax/pascal.syntax +77 -0
  170. data/code/syntax/perl.syntax +1115 -0
  171. data/code/syntax/plain_text.syntax +32 -0
  172. data/code/syntax/postscript.syntax +114 -0
  173. data/code/syntax/processing.syntax +106 -0
  174. data/code/syntax/prolog.syntax +40 -0
  175. data/code/syntax/property_list.syntax +635 -0
  176. data/code/syntax/python.syntax +868 -0
  177. data/code/syntax/python_django.syntax +21 -0
  178. data/code/syntax/qmake_project.syntax +114 -0
  179. data/code/syntax/qt_c++.syntax +26 -0
  180. data/code/syntax/quake3_config.syntax +32 -0
  181. data/code/syntax/r.syntax +81 -0
  182. data/code/syntax/r_console.syntax +16 -0
  183. data/code/syntax/ragel.syntax +201 -0
  184. data/code/syntax/rd_r_documentation.syntax +91 -0
  185. data/code/syntax/regexp.syntax +50 -0
  186. data/code/syntax/release_notes.syntax +46 -0
  187. data/code/syntax/remind.syntax +253 -0
  188. data/code/syntax/restructuredtext.syntax +250 -0
  189. data/code/syntax/rez.syntax +80 -0
  190. data/code/syntax/ruby.syntax +1035 -0
  191. data/code/syntax/ruby_experimental.syntax +145 -0
  192. data/code/syntax/ruby_on_rails.syntax +88 -0
  193. data/code/syntax/s5.syntax +69 -0
  194. data/code/syntax/scheme.syntax +347 -0
  195. data/code/syntax/scilab.syntax +41 -0
  196. data/code/syntax/setext.syntax +147 -0
  197. data/code/syntax/shell-unix-generic.syntax +384 -0
  198. data/code/syntax/slate.syntax +149 -0
  199. data/code/syntax/sql.syntax +237 -0
  200. data/code/syntax/sql_rails.syntax +18 -0
  201. data/code/syntax/ssh-config.syntax +33 -0
  202. data/code/syntax/standard_ml.syntax +121 -0
  203. data/code/syntax/strings_file.syntax +39 -0
  204. data/code/syntax/subversion_commit_message.syntax +36 -0
  205. data/code/syntax/sweave.syntax +84 -0
  206. data/code/syntax/swig.syntax +57 -0
  207. data/code/syntax/tcl.syntax +152 -0
  208. data/code/syntax/template_toolkit.syntax +121 -0
  209. data/code/syntax/tex.syntax +86 -0
  210. data/code/syntax/tex_math.syntax +49 -0
  211. data/code/syntax/textile.syntax +215 -0
  212. data/code/syntax/tsv.syntax +50 -0
  213. data/code/syntax/twiki.syntax +241 -0
  214. data/code/syntax/txt2tags.syntax +79 -0
  215. data/code/syntax/vectorscript.syntax +57 -0
  216. data/code/syntax/xhtml_1.0.syntax +4027 -0
  217. data/code/syntax/xml.syntax +180 -0
  218. data/code/syntax/xml_strict.syntax +92 -0
  219. data/code/syntax/xsl.syntax +60 -0
  220. data/code/syntax/yaml.syntax +160 -0
  221. data/code/syntax/yui_javascript.syntax +176 -0
  222. data/lib/bayeux/bayeux.rb +727 -0
  223. data/lib/bayeux/html_gen.rb +506 -0
  224. data/lib/bayeux/latex_gen.rb +333 -0
  225. data/lib/bayeux/para_block.rb +201 -0
  226. data/lib/bayeux/text_gen.rb +307 -0
  227. data/lib/bayeux/tree_walker.rb +166 -0
  228. data/lib/filters/bayeux.rb +44 -0
  229. data/lib/filters/pandoc.rb +23 -0
  230. data/lib/filters/section_id.rb +105 -0
  231. data/lib/helpers/breadcrumbs.rb +64 -0
  232. data/lib/helpers/site_toc.rb +11 -0
  233. data/lib/lib/uv.rb +92 -0
  234. data/lib/lib/uv/render_processor.rb +146 -0
  235. data/lib/lib/uv/utility.rb +67 -0
  236. data/lib/refs/Doc_Blocks.rb +2 -0
  237. data/lib/refs/References.rb +104 -0
  238. metadata +415 -0
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: Javascript YUI
3
+ scopeName: source.js.yui
4
+ uuid: 62E7EF93-5574-4063-BF18-AD38620236B9
5
+ foldingStartMarker: (^.*{[^}]*$|^.*\([^\)]*$|^.*/\*(?!.*\*/).*$)
6
+ patterns:
7
+ - name: support.class.js.yui
8
+ match: \b(YAHOO|YAHOO_config)\b
9
+ - name: support.class.js.yui
10
+ match: \.(util|lang|env|widget|example)\b
11
+ - name: support.class.js.yui
12
+ match: \.(CustomEvent|Subscriber|Event|EventProvider|Dom|Point|Region|Connect|DD|DDProxy|DDTarget|DragDrop|DragDropMgr|DDM|Anim|AnimMgr|Bezier|ColorAnim|Easing|Motion|Scroll|AutoComplete|DataSource|DS_JSArray|DS_JSFunction|DS_XHR|Config|KeyListener|Attribute|AttributeProvider|Element|History)\b
13
+ - name: support.class.js.yui
14
+ match: \.(AutoComplete|DataSource|DS_JSArray|DS_JSFunction|DS_XHR|Calendar|Calendar2up|Calendar_Core|CalendarGroup|DateMath|Module|Overlay|OverlayManager|Tooltip|Panel|Dialog|SimpleDialog|ContainerEffect|Logger|LogMsg|LogReader|LogWriter|Menu|MenuItem|Menubar|MenuBarItem|MenuManager|MenuModule|MenuModuleItem|ContextMenu|ContextMenuItem|Slider|SliderThumb|Tab|TabView|TreeView|Node|HTMLNode|MenuNode|TextNode|RootNode|TVAnim|TVFadeIn|TVFadeOut|Column|ColumnEditor|ColumnSet|DataTable|Record|RecordSet|Sort|WidthResizer|Button|ButtonGroup)\b
15
+ - name: support.function.YAHOO.js.yui
16
+ match: \.(log|namespace|register)\b(?=\()
17
+ - name: support.function.lang.js.yui
18
+ match: \.(augment|extend|hasOwnProperty|isArray|isBoolean|isFunction|isNull|isNumber|isObject|isString|isUndefined)\b(?=\()
19
+ - name: support.function.Subscriber.js.yui
20
+ match: \.(getScope)\b(?=\()
21
+ - name: support.function.CustomEvent.js.yui
22
+ match: \.(fire|subscribe|unsubscribe|unsubscribeAll)\b(?=\()
23
+ - name: support.function.Event.js.yui
24
+ match: \.(addListener|clearCache|fireLegacyEvent|generateId|getCharCode|getEl|getEvent|getLegacyIndex|getListeners|getPageX|getPageY|getRelatedTarget|getTarget|getTime|getXY|on|onAvailable|onContentReady|preventDefault|purgeElement|removeListener|resolveTextNode|startInterval|stopEvent|stopPropagation|useLegacyEvent)\b(?=\()
25
+ - name: support.function.EventProvider.js.yui
26
+ match: \.(createEvent|fireEvent|hasEvent|subscribe|unsubscribe)\b(?=\()
27
+ - name: support.function.Dom.js.yui
28
+ match: \.(addClass|batch|generateId|get|getClientHeight|getClientWidth|getDocumentHeight|getDocumentWidth|getElementsBy|getElementsByClassName|getRegion|getStyle|getViewportHeight|getViewportWidth|getX|getXY|getY|hasClass|inDocument|isAncestor|removeClass|replaceClass|setStyle|setX|setXY|setY)\b(?=\()
29
+ - name: support.function.Region.js.yui
30
+ match: \.(contains|getArea|intersect|union|getRegion)\b(?=\()
31
+ - name: support.function.Connect.js.yui
32
+ match: \.(abort|appendPostData|asyncRequest|createExceptionObject|createFrame|createResponseObject|createXhrObject|getConnectionObject|handleReadyState|handleTransactionResponse|initHeader|isCallInProgress|releaseObject|resetFormState|setDefaultPostHeader|setForm|setHeader|setPollingInterval|setProgId|uploadFile)\b(?=\()
33
+ - name: support.function.Anim.js.yui
34
+ match: \.(animate|doMethod|getAttribute|getDefaultUnit|getEl|getStartTime|init|isAnimated|onTween|setAttribute|setRuntimeAttribute|stop)\b(?=\()
35
+ - name: support.function.AnimMgr.js.yui
36
+ match: \.(correctFrame|registerElement|run|start|stop|unRegister)\b(?=\()
37
+ - name: support.function.Bezier.js.yui
38
+ match: \.(getPosition)\b(?=\()
39
+ - name: support.function.ColorAnim.js.yui
40
+ match: \.(parseColor)\b(?=\()
41
+ - name: support.function.Easing.js.yui
42
+ match: \.(backBoth|backIn|backOut|bounceBoth|bounceIn|bounceOut|easeBoth|easeBothStrong|easeIn|easeInStrong|easeNone|easeOut|easeOutStrong|elasticBoth|elasticIn|elasticOut)\b
43
+ - name: support.function.Motion.js.yui
44
+ match: \.()\b(?=\()
45
+ - name: support.function.Scroll.js.yui
46
+ match: \.()\b(?=\()
47
+ - name: support.function.DragDrop.js.yui
48
+ match: \.(addInvalidHandleClass|addInvalidHandleId|addInvalidHandleType|addToGroup|applyConfig|b4Drag|b4DragDrop|b4DragOut|b4DragOver|b4EndDrag|b4MouseDown|b4StartDrag|clearConstraints|clearTicks|endDrag|getDragEl|getEl|getTick|handleMouseDown|handleOnAvailable|init|initTarget|isLocked|isValidHandleChild|lock|onAvailable|onDrag|onDragDrop|onDragEnter|onDragOut|onDragOver|onInvalidDrop|onMouseDown|onMouseUp|padding|removeFromGroup|removeInvalidHandleClass|removeInvalidHandleId|removeInvalidHandleType|resetContraints|setDragElId|setHandleElId|setInitPosition|setOuterHandleElId|setPadding|setStartPosition|setXConstraint|setXTicks|setYConstraint|setYTicks|startDrag|unlock|unreg)\b(?=\()
49
+ - name: support.function.DragDropMgr.js.yui
50
+ match: \.(fireEvents|getBestMatch|getClientHeight|getClientWidth|getCss|getDDById|getElement|getElWrapper|getLocation|getPosX|getPosY|getRelated|getScrollLeft|getScrollTop|getStyle|handleMouseDown|handleMouseMove|handleMouseUp|handleWasClicked|init|isDragDrop|isHandle|isLegalTarget|isLocked|isOverTarget|isTypeOfDD|lock|moveToEl|numericSort|refreshCache|regDragDrop|regHandle|removeDDFromGroup|startDrag|stopDrag|stopEvent|swapNode|unlock|unregAll|verifyEl)\b(?=\()
51
+ - name: support.function.DD.js.yui
52
+ match: \.(alignElWithMouse|applyConfig|autoOffset|autoScroll|cachePosition|getTargetCoord|setDelta|setDragElPos)\b(?=\()
53
+ - name: support.function.DDProxy.js.yui
54
+ match: \.(createFrame|initFrame|showFrame)\b(?=\()
55
+ - name: support.function.DDTarget.js.yui
56
+ match: \.()\b(?=\()
57
+ - name: support.function.History.js.yui
58
+ match: \.(getBookmarkedState|getCurrentState|initialize|navigate|register)\b(?=\()
59
+ - name: support.function.DataSource.js.yui
60
+ match: \.(addToCache|flushCache|getCachedResponse|handleResponse|isCacheHit|makeConnection|parseArrayData|parseJSONData|parseTextData|parseXMLData|sendRequest)\b(?=\()
61
+ - name: support.function.AutoComplete.js.yui
62
+ match: \.(doBeforeExpandContainer|formatResult|getListItemData|getListItems|isContainerOpen|sendQuery|setBody|setFooter|setHeader)\b(?=\()
63
+ - name: support.function.DS_JSArray.js.yui
64
+ match: \.()\b(?=\()
65
+ - name: support.function.DS_JSFunction.js.yui
66
+ match: \.()\b(?=\()
67
+ - name: support.function.DS_XHR.js.yui
68
+ match: \.(parseResponse)\b(?=\()
69
+ - name: support.function.Calendar.js.yui
70
+ match: \.(addMonthRenderer|addMonths|addRenderer|addWeekdayRenderer|addYears|applyListeners|buildDayLabel|buildMonthLabel|buildWeekdays|clear|clearAllBodyCellStyles|clearElement|configClose|configIframe|configLocale|configLocaleValues|configMaxDate|configMinDate|configOptions|configPageDate|configSelected|configTitle|deselect|deselectAll|deselectCell|doCellMouseOut|doCellMouseOver|doSelectCell|getDateByCellId|getDateFieldsByCellId|getSelectedDates|hide|init|initEvents|initStyles|isDateOOM|nextMonth|nextYear|onBeforeDeselect|onBeforeSelect|onChangePage|onClear|onDeselect|onRender|onReset|onSelect|previousMonth|previousYear|refreshLocale|render|renderBody|renderBodyCellRestricted|renderCellDefault|renderCellNotThisMonth|renderCellStyleHighlight1|renderCellStyleHighlight2|renderCellStyleHighlight3|renderCellStyleHighlight4|renderCellStyleSelected|renderCellStyleToday|renderFooter|renderHeader|renderOutOfBoundsDate|renderRowFooter|renderRowHeader|reset|resetRenderers|select|selectCell|setMonth|setYear|show|styleCellDefault|subtractMonths|substractYears|validate)\b(?=\()
71
+ - name: support.function.CalendarGroup.js.yui
72
+ match: \.(addMonthRenderer|addMonths|addRenderer|addWeekdayRenderer|addYears|callChildFunction|clear|configPageDate|configPages|constructChild|delegateConfig|deselect|deselectAll|deselectCell|getSelectedDates|init|initEvents|nextMonth|nextYear|previousMonth|previousYear|render|renderFooter|renderHeader|reset|select|selectCell|setChildFunction|setMonth|setYear|sub|subtractMonths|subtractYears|unsub)\b(?=\()
73
+ - name: support.function.DateMath.js.yui
74
+ match: \.(add|after|before|between|clearTime|findMonthEnd|findMonthStart|getDayOffset|getJan1|getWeekNumber|isMonthOverlapWeek|isYearOverlapWeek|subtract)\b(?=\()
75
+ - name: support.function.Config.js.yui
76
+ match: \.(addProperty|alreadySubscribed|applyConfig|checkBoolean|checkNumber|fireEvent|fireQueue|getConfig|getProperty|init|outputEventQueue|queueProperty|refireEvent|refresh|resetProperty|setProperty|subscribeToConfigEvent|unsubscribeFromConfigEvent)\b(?=\()
77
+ - name: support.function.KeyListener.js.yui
78
+ match: \.(disable|enable|handleKeyPress)\b(?=\()
79
+ - name: support.function.Module.js.yui
80
+ match: \.(appendToBody|appendToFooter|appendToHeader|configMonitorResize|configVisible|destroy|hide|init|initDefaultConfig|initEvents|initResizeMonitor|onDomResize|render|setBody|setFooter|setHeader|show)\b(?=\()
81
+ - name: support.function.Overlay.js.yui
82
+ match: \.(align|center|configConstrainToViewport|configContext|configFixedCenter|configHeight|configIframe|configVisible|configWidth|configX|configXY|configY|configZIndex|destroy|doCenterOnDOMEvent|enforceContraints|hideIframe|hideMacGeckoScrollbars|init|initDefaultConfig|initEvenrts|moveTo|onDomResize|showIframe|showMacGeckoScrollbars|syncPosition|windowResizeHandle|windowScrollHandler)\b(?=\()
83
+ - name: support.function.OverlayManager.js.yui
84
+ match: \.(blurAll|compareZIndexDesc|find|focus|getActive|hideAll|init|initDefaultConfig|register|remove|showAll)\b(?=\()
85
+ - name: support.function.Tooltip.js.yui
86
+ match: \.(configContainer|configContext|configText|doHide|doShow|init|initDefaultConfig|onContextMouseMove|onContextMouseOut|onContextMouseOver|preventOverlay)\b(?=\()
87
+ - name: support.function.Panel.js.yui
88
+ match: \.(buildMask|buildWrapper|configClose|configDraggable|configHeight|configKeyListeners|configModal|configUnderlay|configWidth|configzIndex|hideMask|init|initDefaultConfig|initEvents|onDomResize|registerDragDrop|removeMask|render|showMask|sizeMask|sizeUnderlay)\b(?=\()
89
+ - name: support.function.Dialog.js.yui
90
+ match: \.(blurButtons|cancel|configButtons|doSubmit|focusDefaultButton|focusFirst|focusFirstButton|focusLast|focusLastButton|getData|init|initDefaultConfig|initEvents|registerForm|submit|validate)\b(?=\()
91
+ - name: support.function.SimpleDialog.js.yui
92
+ match: \.(configIcon|configText|init|initDefaultConfig|registerForm)\b(?=\()
93
+ - name: support.function.ContainerEffect.js.yui
94
+ match: \.(animateIn|animateOut|FADE|handleCompleteAnimateIn|handleCompleteAnimateOut|handleStartAnimateIn|handleStartAnimateOut|handleTweenAnimateIn|handleTweenAnimateOut|init|SLIDE)\b(?=\()
95
+ - name: support.function.Logger.js.yui
96
+ match: \.(disableBrowserConsole|enableBrowserConsole|getStack|getStartTime|log|reset)\b(?=\()
97
+ - name: support.function.LogMsg.js.yui
98
+ match: \.()\b(?=\()
99
+ - name: support.function.LogReader.js.yui
100
+ match: \.(formatMsg|getLastTime|hide|html2Text|pause|resume|setTitle|show)\b(?=\()
101
+ - name: support.function.LogWriter.js.yui
102
+ match: \.(getSource|log|setSource)\b(?=\()
103
+ - name: support.function.Menu.js.yui
104
+ match: \.(addItem|addItems|clearActiveItem|configContainer|configHideDelay|configIframe|configPosition|configVisible|destroy|disableAutoSubmenuDisplay|enforceConstraints|getItem|getItemGroups|getRoot|init|initDefaultConfig|initEvents|insertItem|onDomResize|removeItem|setInitialFocus|setInitialSelection|setItemGroupTitle)\b(?=\()
105
+ - name: support.function.MenuItem.js.yui
106
+ match: \.(blur|configChecked|configDisabled|configEmphasis|configHelpText|configSelected|configStrongEmphasis|configSubmenu|configTarget|configText|configUrl|destroy|focus|getFirstItemIndex|getNextArrayItem|getNextEnabledSibling|getPreviousArrayItem|getPreviousEnabledSibling|init|initDefaultConfig|initHelpText|removeHelpText)\b(?=\()
107
+ - name: support.function.Menubar.js.yui
108
+ match: \.(init|initDefaultConfig)\b(?=\()
109
+ - name: support.function.MenuBarItem.js.yui
110
+ match: \.(init)\b(?=\()
111
+ - name: support.function.MenuManager.js.yui
112
+ match: \.(addItem|addMenu|getMenu|getMenuRootElement|getMenus|hideVisible|onDOMEvent|onItemAdded|onItemDestroy|onItemRemoved|onMenuDestroy|onMenuVisibleConfigChange|removeItem|removeMenu)\b(?=\()
113
+ - name: support.function.MenuModule.js.yui
114
+ match: \.()\b(?=\()
115
+ - name: support.function.MenuModuleItem.js.yui
116
+ match: \.()\b(?=\()
117
+ - name: support.function.ContextMenu.js.yui
118
+ match: \.(configTrigger|destroy|init|initDefaultConfig)\b(?=\()
119
+ - name: support.function.ContextMenuItem.js.yui
120
+ match: \.(init)\b(?=\()
121
+ - name: support.function.Slider.js.yui
122
+ match: \.(b4MouseDown|endMove|fireEvents|focus|getThumb|getValue|getXValue|getYValue|handleThumbChange|lock|moveOneTick|moveThumb|onChange|onDrag|onMouseDown|onSliderEnd|onSlideStart|setRegionValue|setSliderStartState|setThumbCenterPoint|setValue|thumbMouseUp|unlock|verifyOffset|getHorizSlider|getSliderRegion|getVertSlider)\b(?=\()
123
+ - name: support.function.SliderThumb.js.yui
124
+ match: \.(clearTicks|getOffsetFromParent|getValue|getXValue|getYValue|initSlider|onChange)\b(?=\()
125
+ - name: support.function.AttributeProvider.js.yui
126
+ match: \.(configureAttribute|fireBeforeChangeEvent|fireChangeEvent|get|getAttributeConfig|getAttributeKeys|refresh|register|resetAttributeConfig|resetValue|set|setAttributes)\b(?=\()
127
+ - name: support.function.Attribute.js.yui
128
+ match: \.(configure|getValue|refresh|resetConfig|resetValue|setValue|getValue|refresh|resetConfig|resetValue|setValue)\b(?=\()
129
+ - name: support.function.Element.js.yui
130
+ match: \.(addClass|addListener|appendChild|appendTo|fireQueue|getElementsByClassName|getElementsByTagName|getStyle|hasChildNodes|hasClass|initAttributes|insertBefore|on|removeChild|removeClass|removeListener|replaceChild|replaceClass|setStyle)\b(?=\()
131
+ - name: support.function.TabView.js.yui
132
+ match: \.(addTab|contentTransition|createTabs|DOMEventHandler|getTab|getTabIndex|initAttributes|removeTab)\b(?=\()
133
+ - name: support.function.Tab.js.yui
134
+ match: \.(initAttributes)\b(?=\()
135
+ - name: support.function.TreeView.js.yui
136
+ match: \.(animateCollapse|animateExpand|collapseAll|collapseComplete|draw|expandAll|expandComplete|generateId|getEl|getNodeByIndex|getNodeByProperty|getNodesByProperty|getRoot|init|onCollapse|onExpand|popNode|regNode|removeChildren|removeNode|setCollapseAnim|setDynamicLoad|setExpandAnim|setUpLabel|addHandler|getNode|getTree|preload|removeHandler)\b(?=\()
137
+ - name: support.function.Node.js.yui
138
+ match: \.(appendChild|appendTo|applyParent|collapseToggleStyle|collapseAll|completeRender|expand|expandAll|getAncestor|getChildrenEl|getChildrenElId|getChildrenHtml|getDepthStyle|getEl|getElId|getHoverStyle|getHtml|getIconMode|getNodeHtml|getSiblings|getStyle|getToggleEl|getToggleElId|getToggleLink|hasChildren|hideChildren|init|insertAfter|insertBefore|isChildOf|isDynamic|isRoot|loadComplete|refresh|renderChildren|setDynamicLoad|showChildren|toggle)\b(?=\()
139
+ - name: support.function.HTMLNode.js.yui
140
+ match: \.(getContentEl)\b(?=\()
141
+ - name: support.function.MenuNode.js.yui
142
+ match: \.()\b(?=\()
143
+ - name: support.function.TextNode.js.yui
144
+ match: \.(getLabelEl|onLabelClick)\b(?=\()
145
+ - name: support.function.RootNode.js.yui
146
+ match: \.()\b(?=\()
147
+ - name: support.function.TVAnim.js.yui
148
+ match: \.(getAnim|isValid)\b(?=\()
149
+ - name: support.function.TVFadeIn.js.yui
150
+ match: \.(animate|onComplete)\b(?=\()
151
+ - name: support.function.TVFadeOut.js.yui
152
+ match: \.(animate|onComplete)\b(?=\()
153
+ - name: support.function.Column.js.yui
154
+ match: \.(format|formatCheckbox|formatCurrency|formatDate|formatEmail|formatLink|formatNumber|formatSelect|getColSpan|getId|getRowSpan|parse|parseCheckbox|parseCurrency|parseDate|parseNumber|parseSelect|showEditor)\b(?=\()
155
+ - name: support.function.ColumnEditor.js.yui
156
+ match: \.(createTextareaEditor|createTextboxEditor|getTextareaEditorValue|getTextboxEditorValue|getValue|hide|show|showTextareaEditor|showTextboxEditor)\b(?=\()
157
+ - name: support.function.ColumnSet.js.yui
158
+ match: \.()\b(?=\()
159
+ - name: support.function.DataTable.js.yui
160
+ match: \.(addRow|appendRow|deleteRow|deleteSelectedRows|doBeforeLoadData|editCell|focusTable|formatCell|getBody|getCell|getColumnSet|getHead|getRecordSet|getRow|getSelectedCells|getSelectedRecordIds|getSelectedRows|getTable|hideTableMessages|highlight|insertRows|isSelected|onDataReturnAppendRows|onDataReturnInsertRows|onDataReturnPaginateRows|onDataReturnReplaceRows|onEventEditCell|onEventFormatCell|onEventHighlightCell|onEventSelectCell|onEventSelectRow|onEventSortColumn|onEventUnhighlightCell|paginateRows|replaceRows|select|showEmptyMessage|showLoadingMessage|showPage|sortColumn|unhighlight|unselect|unselectedAllCells|unselectAllRows|updateRow)\b(?=\()
161
+ - name: support.function.Record.js.yui
162
+ match: \.()\b(?=\()
163
+ - name: support.function.RecordSet.js.yui
164
+ match: \.(addRecord|addRecords|append|deleteRecord|getLength|getRecord|getRecordBy|getRecordIndex|getRecords|insert|replace|reset|sort|updateRecord)\b(?=\()
165
+ - name: support.function.Sort.js.yui
166
+ match: \.(compareAsc|compareDesc)\b(?=\()
167
+ - name: support.function.WidthResizer.js.yui
168
+ match: \.(onDrag|onMouseDown|onMouseUp)\b(?=\()
169
+ - name: support.function.Button.js.yui
170
+ match: \.(addHiddenFieldsToForm|blur|createHiddenField|createInputElement|destroy|focus|getFirstElement|getForm|getMenu|hasFocus|init|initAttributes|initConfig|isActive|setAttributeFromDOMAttribute|setAttributesFromSrcElement|setFormElementProperties)\b(?=\()
171
+ - name: support.function.ButtonGroup.js.yui
172
+ match: \.(addButton|addButtons|check|destroy|focus|getButton|getButtons|getCount|init|initAttributes|removeButton)\b(?=\()
173
+ - include: source.js
174
+ foldingStopMarker: (^\s*\}|^\s*\)|^(?!.*/\*).*\*/)
175
+ keyEquivalent: ^~J
176
+ comment: Yahoo User Interface Library
@@ -0,0 +1,727 @@
1
+ require 'set'
2
+ require 'tree'
3
+ require 'facets'
4
+
5
+ require 'log4r'
6
+ include Log4r
7
+
8
+ class Bayeux
9
+
10
+ # Start parsing
11
+ def parse(content)
12
+
13
+ # Set-up the logger
14
+ @parse_log = Logger.new('bayex_parser')
15
+ @parse_log.outputters = Outputter.stdout
16
+
17
+ # Save the content for later
18
+ @content = content
19
+
20
+ # Final string to return to the caller
21
+ pandoc_str = String.new
22
+
23
+ # Forest containing the paragraph level block trees
24
+ @block_forest = Array.new
25
+
26
+ # Index of the paragraph blocks
27
+ @block_index = 0
28
+
29
+ # Indicies into the content, denoting the current limits of
30
+ # parsing
31
+ from_index = 0
32
+ to_index = content.length
33
+
34
+ ## Procedure for adding a node to the tree
35
+ new_node = ->(node_type = :none, node_contents = ""){
36
+
37
+ @block_index += 100
38
+ @parse_log.info {"creating node #{@block_index}"}
39
+ return Tree::TreeNode.new(@block_index, ParaBlock.new(node_type, node_contents))
40
+
41
+ }
42
+
43
+ # Chunk the content into paragraph blocks
44
+ while from_index < to_index do
45
+
46
+ # Look for the next space, and the next next '[' character
47
+ # which should tell us what type of paragraph we are dealing with
48
+ space_index = content.index(' ', from_index)
49
+ left_sb_index = content.index(']', from_index)
50
+ block_start = content.index('[', from_index)
51
+
52
+ if block_start.nil? then
53
+ # It's a paragraph
54
+ unless space_index.nil? then
55
+ block = ParaBlock.new(:paragraph, "")
56
+ block_start = from_index
57
+ else
58
+ # No more blocks
59
+ break
60
+ end
61
+ elsif (left_sb_index < space_index) and (left_sb_index > block_start) then
62
+ # This should be a block start marker
63
+ orig_type_length = (left_sb_index - 1) - block_start
64
+ block = ParaBlock.from_s(content[block_start + 1, orig_type_length])
65
+
66
+ elsif space_index > block_start then
67
+ # This should be an annotated block
68
+ orig_type_length = space_index - (block_start + 1)
69
+ block = ParaBlock.from_s(content[block_start + 1, orig_type_length])
70
+
71
+ elsif space_index < block_start then
72
+ # It's a paragraph
73
+ unless space_index.nil? then
74
+ block = ParaBlock.new(:paragraph, "")
75
+ block_start = from_index
76
+ else
77
+ @parse_log.error {"Cannot find a valid block (syntax error in the start of block characters)"}
78
+ return nil
79
+ end
80
+ end
81
+
82
+ # Now we know the type of block, and where it starts, work out
83
+ # where the end of the block is
84
+ case block.type
85
+ when :h1,:h2,:h3,:h4,:h5,:h6,:bib
86
+ # Look for a terminating ']'
87
+ block_end = left_sb_index
88
+
89
+ # Add the node, and paragraph sub_tree, to the block forest
90
+ block.content = content_string(block_start + 4, block_end)
91
+ para_node = Tree::TreeNode.new(@block_index, block)
92
+ para_subtree(para_node)
93
+ @block_forest << para_node
94
+
95
+ when :paragraph
96
+ # Look for a single new line, containing only whitespace
97
+ block_end = content.index(/^\s/, block_start)
98
+
99
+ # Add a node to the block forest
100
+ block.content = content_string(block_start, block_end)
101
+ para_node = Tree::TreeNode.new(@block_index, block)
102
+ para_subtree(para_node)
103
+ @block_forest << para_node
104
+
105
+ when :medskip
106
+ # Self-terminating
107
+ block_end = block_start + 9
108
+
109
+ # Add a node to the block forest
110
+ para_node = Tree::TreeNode.new(@block_index, block)
111
+ @block_forest << para_node
112
+
113
+ when :command, :output, :file
114
+ # Look for a terminating '[end]'
115
+ block_end = content.index('[end]', block_start)
116
+ content_index = block_start + (block.orig_type_length + 2)
117
+
118
+ # Add a node to the block forest, and do no further processing
119
+ block.content = content_string(content_index, block_end)
120
+ para_node = Tree::TreeNode.new(@block_index, block)
121
+ @block_forest << para_node
122
+
123
+ # Skip the 'end'
124
+ block_end += 5
125
+
126
+ when :code
127
+ # Look for a terminating '[end]'
128
+ block_end = content.index('[end]', block_start)
129
+ content_index = block_start + (block.orig_type_length + 2)
130
+
131
+ # Look for arguments to the block
132
+ unless content[from_index + 1] == ']' then
133
+
134
+ # Find the end of the arguments
135
+ arg_end = content.index(/]\s/, from_index)
136
+ arguments = content[from_index + 6, (arg_end - (from_index + 6))]
137
+
138
+ # Create the parent node for this content
139
+ code_start = content.index(/^/, arg_end)
140
+ block.content = content_string(code_start, block_end)
141
+ para_node = Tree::TreeNode.new(@block_index, block)
142
+
143
+ # Split the item
144
+ items = arguments.split('|')
145
+
146
+ # Create a node for the description title
147
+ unless items[0].nil? then
148
+ para_node << new_node.call(:code_language, items[0].strip)
149
+ else
150
+ para_node << new_node.call(:code_language, "")
151
+ end
152
+
153
+ # Create the description text
154
+ unless items[1].nil? then
155
+ para_node << new_node.call(:code_start_number, items[1].strip)
156
+ else
157
+ para_node << new_node.call(:code_start_number, "0")
158
+ end
159
+
160
+ else
161
+
162
+ # Create the parent node for this content
163
+ block.content = content_string(content_index, block_end)
164
+ para_node = Tree::TreeNode.new(@block_index, block)
165
+
166
+ para_node << new_node.call(:code_language, "")
167
+ para_node << new_node.call(:code_start_number, "0")
168
+
169
+ end
170
+
171
+ # Add a node to the block forest, and do no further processing
172
+ @block_forest << para_node
173
+
174
+ # Skip the 'end'
175
+ block_end += 5
176
+
177
+ when :block_quote, :figure, :note, :quote
178
+ # Look for a terminating '[end]'
179
+ block_end = content.index('[end]', block_start)
180
+ content_index = block_start + (block.orig_type_length + 2)
181
+
182
+ # Add a node to the block forest
183
+ block.content = content_string(content_index, block_end)
184
+ para_node = Tree::TreeNode.new(@block_index, block)
185
+ para_subtree(para_node)
186
+ @block_forest << para_node
187
+
188
+ # Skip the 'end'
189
+ block_end += 5
190
+
191
+ when :dl
192
+ # Look for a terminating '[end]'
193
+ block_end = content.index('[end]', block_start)
194
+
195
+ ## Description List blocks are really two blocks, so should be
196
+ ## parsed as such. First we look for (and parse) the description
197
+ ## header, then we look for (and parse) the description body. We
198
+ ## keep doing this until we run out of things to do.
199
+
200
+ # Create the master node for the list
201
+ dl_node = new_node.call(:dl)
202
+
203
+ # Get the list contents
204
+ content_index = block_start + (block.orig_type_length + 2)
205
+ list_content = content_string(content_index, block_end)
206
+
207
+ # First break the list into components
208
+ list_items = list_content.split(/^\n/)
209
+
210
+ # Process each list item
211
+ list_items.each{|list_item|
212
+
213
+ # Break the list item into a description header and
214
+ # description body
215
+ break_at = list_item.index(/:$/)
216
+ item_index = list_item.index('[item')
217
+ item_end = list_item.rindex(']')
218
+
219
+ description_header = list_item[item_index + 5, break_at - 5]
220
+ description_body = list_item[break_at + 1, (item_end - break_at - 1)]
221
+
222
+ # Parse the description header
223
+ header_node = new_node.call(:dl_header, description_header)
224
+ para_subtree(header_node)
225
+ dl_node << header_node
226
+
227
+ # Parse the description body
228
+ body_node = new_node.call(:dl_text, description_body)
229
+ para_subtree(body_node)
230
+ dl_node << body_node
231
+
232
+ }
233
+
234
+ # Add the node to the block forest
235
+ @block_forest << dl_node
236
+
237
+ # Skip the 'end'
238
+ block_end += 5
239
+
240
+ when :ol, :ul
241
+ # Lists are special because they can be nested. Hence we
242
+ # have to be a bit careful about the end marker.
243
+ block_end = content.index(/\[end\]((\n\n)|($\z))/, block_start)
244
+
245
+ if block_end.nil? then
246
+ @parse_log.error {"Error: Invalid end to a list"}
247
+ @parse_log.error {"Backtrace: #{to_s}"}
248
+ return nil
249
+ end
250
+
251
+ # Add a node to the block forest
252
+ block.content = content_string(block_start + 4, block_end)
253
+ para_node = Tree::TreeNode.new(@block_index, block)
254
+ para_subtree(para_node)
255
+ @block_forest << para_node
256
+
257
+ # Skip the 'end'
258
+ block_end += 5
259
+
260
+ else
261
+ @parse_log.error {"Error: Unknown block type '#{block.type}'"}
262
+ @parse_log.error {"Backtrace: #{to_s}"}
263
+ return nil
264
+
265
+ end
266
+
267
+ @block_index += 100
268
+
269
+ # Skip spaces
270
+ unless block_end.nil? then
271
+ from_index = block_end + 1
272
+ until not (content[from_index] =~ /\n/) do
273
+ from_index += 1
274
+ end
275
+ else
276
+ return nil
277
+ end
278
+
279
+ end
280
+
281
+ end
282
+
283
+ ###
284
+ ### Generators: Convinience functions taking an AST (Abstract Syntax Tree),
285
+ ### and returning a document of the specified type
286
+ ###
287
+
288
+ def to_s
289
+ return_str = String.new
290
+ @block_forest.each{|tree|
291
+ return_str << "Paragraph Type: #{tree.content.type}\n"
292
+ return_str << "\n"
293
+
294
+ tree.each{|node|
295
+ return_str << " Node Name: #{node.name}\n"
296
+ return_str << " Node Type: #{node.content.type}\n"
297
+ return_str << " Node Depth: #{node.node_depth}\n"
298
+
299
+ node_content = node.content.content.inspect.line_wrap(70,2).indent(17)
300
+ return_str << " Node Contents: |#{node_content[17, node_content.length]}|\n\n"
301
+ }
302
+ }
303
+ return return_str
304
+ end
305
+
306
+ def to_json(*a)
307
+ begin
308
+ require 'json'
309
+
310
+ json_hash = {
311
+ "block_forest" => @block_forest,
312
+ JSON.create_id => self.class.name
313
+ }
314
+
315
+ return json_hash.to_json
316
+
317
+ rescue LoadError
318
+ warn "The JSON gem couldn't be loaded, and so the JSON representation could not be generated"
319
+ end
320
+ end
321
+
322
+ def self.json_create(json_hash)
323
+ begin
324
+ require 'json'
325
+
326
+ syntax_tree = new(json_hash["block_forest"])
327
+ return syntax_tree
328
+
329
+ rescue LoadError
330
+ warn "The JSON gem couldn't be loaded, and so the JSON representation could not be generated"
331
+ end
332
+ end
333
+
334
+ ###
335
+ ### Accessors
336
+ ###
337
+
338
+ attr_reader :block_forest
339
+
340
+ ###
341
+ ### Helper functions
342
+ ###
343
+
344
+ def content_string(first, last)
345
+ unless first.nil? or last.nil? then
346
+ return @content[first, (last - first)]
347
+ else
348
+ return ""
349
+ end
350
+ end
351
+
352
+ # Return the sub-tree of paragraph blocks, given a suitably initalised
353
+ # root of a tree
354
+ def para_subtree(tree_root)
355
+
356
+ # Set containing the next codepoints to search for
357
+ stop_at = Set.new [10,12,13,32,34,45,46,91,93]
358
+
359
+ # Value of the current block
360
+ block_index = tree_root.name.to_i
361
+
362
+ # Flag indicating the start of a new block
363
+ block_start = false
364
+
365
+ # String holding the list of characters to parse
366
+ content_string = tree_root.content.to_s
367
+
368
+ # Massage the content string to replace pseudo-blocks
369
+ content_string.gsub!(/\s'([^']+)'/, ' [single_quote \1]')
370
+
371
+ # Index into the content string
372
+ string_index = 0
373
+
374
+ ## Procedure for adding a node to the tree
375
+ new_node = ->(node_type = :none, node_contents = ""){
376
+
377
+ block_index += 1
378
+ @parse_log.debug {"creating node #{block_index}"}
379
+ return Tree::TreeNode.new(block_index, ParaBlock.new(node_type, node_contents))
380
+
381
+ }
382
+
383
+ # Register holding the current paragraph string being built
384
+ register = new_node.call
385
+
386
+ # Add new nodes to here
387
+ add_to = tree_root
388
+
389
+ ## Procedure for attaching the tree node held in the register to the current attachment
390
+ ## point of the growing tree
391
+ attach_register = -> {
392
+
393
+ begin
394
+ @parse_log.debug {" > attaching node #{register.name} as a child of #{add_to.name} (#{register.content.to_debug_s})"}
395
+ add_to << register
396
+ rescue
397
+ tree_root.print_tree
398
+ raise
399
+ end
400
+
401
+ }
402
+
403
+ ## Procedure for adding the register to the tree, at the current level. This also
404
+ ## creates a new node at the same level, and sets the register to point to that
405
+ ## node
406
+ add_current_node = -> {
407
+
408
+ # Save a pointer to the current node
409
+ attach_register.call
410
+
411
+ # Add a new node at the same level as the current_node
412
+ register = new_node.call
413
+
414
+ }
415
+
416
+ ## Procedure for down the tree. This involves saving the current contents of the
417
+ ## register as a new node at the current level, then creating a new node as a child
418
+ move_down_tree = -> {
419
+ @parse_log.debug {"-> going down #{register.name} (#{register.content.to_debug_s})"}
420
+
421
+ # Save the current node, pointed to by the register
422
+ attach_register.call
423
+
424
+ # Add future nodes as the child of this node
425
+ add_to = register
426
+
427
+ # Create a new node as the first child
428
+ register = new_node.call
429
+
430
+ # Flag the start of a new block
431
+ block_start = true
432
+ }
433
+
434
+ ## Procedure for moving up the tree, from the current node
435
+ ## (identified by the register), to the next level up
436
+ move_up_tree = -> {
437
+ @parse_log.debug {"<- going up #{register.name} (#{register.content.to_debug_s})"}
438
+
439
+ # Save the current node, pointed to by the register
440
+ attach_register.call
441
+
442
+ # Move up the tree
443
+ add_to = add_to.parent
444
+ register = new_node.call
445
+
446
+ # Remove any 'empty' children (sub-tree nodes that we might
447
+ # have just added, but which in fact could be trimmed)
448
+ #clean_children.call
449
+
450
+ }
451
+
452
+ ###
453
+ ### Parse the content
454
+ ###
455
+
456
+ content_string.each_codepoint{|codepoint|
457
+
458
+ # Check if we need to stop, in order to process the next block
459
+ if stop_at.include?(codepoint) then
460
+
461
+ # If a stop has been requested, undertake the action
462
+ # indicated by the current codepoint
463
+ case codepoint
464
+
465
+ # Check if this is a new block (we may be dealing with a block
466
+ # terminated by a new-line, instead of a space)
467
+ when 10,12,13
468
+
469
+ if block_start then
470
+
471
+ # Record the block type, and re-set the register content
472
+ register.content.content_to_type!
473
+
474
+ # Unset the start of a new block flag
475
+ block_start = false
476
+
477
+ elsif not ((register.content.empty?) or (content_string[string_index - 1] =~ /^\s/)) then
478
+ # Otherwise treat the new-line as a space, but suppress multiple spaces
479
+ register.content << " "
480
+ end
481
+
482
+ # On a space character, first check if the flag indicating the start
483
+ # of a block. If set, this should indicate that this space follows the
484
+ # name of the block
485
+ when 32
486
+
487
+ if block_start then
488
+
489
+ # Record the block type if not already set
490
+ if register.content.type == :none then
491
+ register.content.content_to_type!
492
+ else
493
+ register.content << " "
494
+ end
495
+
496
+ # Unset the start of a new block flag
497
+ block_start = false
498
+
499
+ else
500
+
501
+ # If this is not the start of a block, pass on the space (but suppress multiple spaces)
502
+ unless content_string[string_index - 1] =~ /^\s/ then
503
+ register.content << " "
504
+ end
505
+
506
+ end
507
+
508
+ # On a double quote, we need to check if this is a special block (the single
509
+ # quote block), or something else
510
+ when 34
511
+
512
+ # If the last character was whitespace, this should be the start of
513
+ # a single quote block
514
+ if content_string[string_index - 1] =~ /\s|\W/ then
515
+
516
+ # Create a new sub-block of the current block
517
+ move_down_tree.call
518
+
519
+ # Set the block type
520
+ register.content.type = :double_quote
521
+
522
+ # If the next character is not alphanumeric, then this should be the
523
+ # end of a single quote block
524
+ elsif not content_string[string_index + 1] =~ /\w/ then
525
+
526
+ # Move back to the parent of the quote block
527
+ move_up_tree.call
528
+
529
+ # No significance, so pass it on
530
+ else
531
+ register.content << "'"
532
+ end
533
+
534
+ # Count the minus signs: this could be a hypen, an em-dash or an en-dash
535
+ when 45
536
+
537
+ if content_string[string_index + 1] =~ /\s|\w/ and not content_string[string_index + 1] == '-' then
538
+
539
+ if ((content_string[string_index - 1] == '-') and (content_string[string_index - 2] == '-')) then
540
+
541
+ # Add the current content, and create a new node at the same level
542
+ add_current_node.call
543
+
544
+ # Change the type of the register, and add it to the tree (which also
545
+ # create a new new at the same level for the following content)
546
+ register.content.type = :em_dash
547
+ add_current_node.call
548
+
549
+ elsif content_string[string_index - 1] == '-'
550
+
551
+ # Add the current content, and create a new node at the same level
552
+ add_current_node.call
553
+
554
+ # Change the type of the register, and add it to the tree (which also
555
+ # create a new new at the same level for the following content)
556
+ register.content.type = :en_dash
557
+ add_current_node.call
558
+
559
+ else
560
+ register.content << "-"
561
+ end
562
+
563
+ end
564
+
565
+ # Count the dots: this could be an elipses
566
+ when 46
567
+ register.content << "."
568
+
569
+ if content_string[string_index + 1] =~ /\s|\w|$/ then
570
+
571
+ # Work out how many dots there are
572
+ split = register.content.content.rpartition(/\s|\w/)
573
+
574
+ unless split[0].empty? then
575
+
576
+ case split[2].length
577
+
578
+ when 3
579
+ register.content.content = split[0] + split[1]
580
+ add_current_node.call
581
+
582
+ register.content.type = :elipses
583
+ add_current_node.call
584
+
585
+ when 4
586
+ add_current_node.call
587
+ register.content.content = split[0] + split[1]
588
+
589
+ register.content.type = :elipses_stop
590
+ add_current_node.call
591
+ end
592
+ end
593
+ end
594
+
595
+
596
+ # On the start of a new block, first record the old block
597
+ # then initialize the new
598
+ when 91
599
+
600
+ # Move down the tree
601
+ move_down_tree.call
602
+
603
+ # Flag the start of a new block
604
+ block_start = true
605
+
606
+ # At the termination of a block, transform the block text to the
607
+ # literal equivalent
608
+ when 93
609
+
610
+ ## Do any special processing ##
611
+
612
+ # Supress block characters from lists that are
613
+ # dealt with elsewhere
614
+ if register.content.type == :none then
615
+
616
+ case register.content.to_s
617
+ when "end", "ol", "ul"
618
+ register.content.clear
619
+ end
620
+
621
+ end
622
+
623
+ # Split items in links
624
+ if register.content.type == :link then
625
+ # Split the item
626
+ items = register.content.to_s.split('|')
627
+
628
+ # Create a node for the link title
629
+ unless items[0].nil? then
630
+ title = new_node.call(:link_text, items[0].strip)
631
+ register << title
632
+ end
633
+
634
+ # Create a node for the link target
635
+ unless items[1].nil? then
636
+ target = new_node.call(:link_target, items[1].strip)
637
+ register << target
638
+ end
639
+ end
640
+
641
+ # Add the register to the tree, and move back up to
642
+ # the previous level
643
+ move_up_tree.call
644
+
645
+ end
646
+ else
647
+ # If we are not stopping, just add the codepoint to the register
648
+ register.content << codepoint
649
+ end
650
+
651
+ # Increment the string index
652
+ string_index += 1
653
+
654
+ }
655
+
656
+ # Add the last node to the tree
657
+ attach_register.call
658
+
659
+ ## Prune any null nodes: this makes the tree smaller, and means we can idenify
660
+ ## places where the branches need to be re-ordered
661
+
662
+ tree_root.each{|node|
663
+ if node.content.type == :none and node.content.empty? then
664
+ @parse_log.debug {"--- pruning node #{node.name}"}
665
+ node.remove_from_parent!
666
+ end
667
+ }
668
+
669
+ ## Now we need to walk the AST, patching up the types so that enclosing
670
+ ## types work properly. This requires finding all the :none nodes, and
671
+ ## working out the correct type from the found siblings. To make sure
672
+ ## we infer the correct type, we need to do a breadth first walk
673
+
674
+ tree_root.breadth_each{|node|
675
+
676
+ # First look 'across' the tree, looking for cases where enclosing node
677
+ # have not been properly identified
678
+ if node.is_first_sibling? then
679
+
680
+ # Check the type of the last sibling: if this is :none, then
681
+ # we have something like a list, where the paragraph text needs to
682
+ # be separated from the element type
683
+ if node.first_sibling.content.type != :none and node.last_sibling.content.type == :none then
684
+ @parse_log.info {"examining node #{node.name}"}
685
+
686
+ # Patch the type hierarchy. The easiest way to do this is to
687
+ # look for a parent whose type is also :none: if found we can
688
+ # 'borrow' the node as the item type
689
+ if node.parent.content.type == :none and node.parent.content.empty? then
690
+ @parse_log.info {"changing parent type"}
691
+ node.parent.content.type = node.content.type
692
+ node.content.type = :none
693
+
694
+ # Otherwise we have to work a bit harder, separating us and
695
+ # our siblings, creating a new node of the correct type, and
696
+ # binding everything back together
697
+ else
698
+ @parse_log.info {"re-ordering siblings"}
699
+ siblings = node.siblings
700
+
701
+ new_root = new_node.call(node.content.type)
702
+ node.parent << new_root
703
+
704
+ node.remove_from_parent!
705
+ new_root << node
706
+ siblings.each{|node|
707
+ @parse_log.info {"removing node #{node.name}"}
708
+ @parse_log.info {"attaching to #{new_root.name}"}
709
+ node.remove_from_parent!
710
+ new_root << node
711
+ }
712
+
713
+ end
714
+
715
+ end
716
+ end
717
+ }
718
+
719
+ # We need to preserve the children, so delete the content from
720
+ # the parent to tell users of the AST to walk our children
721
+ tree_root.content.clear
722
+
723
+ end
724
+
725
+ private :para_subtree
726
+
727
+ end