seikichi / restructured

Pure JavaScript reStructuredText parser
58 stars 15 forks source link

TypeError: Elements.InterpretedText is not a constructor #2

Closed bgotink closed 7 years ago

bgotink commented 7 years ago

The last version no longer supports references:

$ echo 'Foo :ref:`bar`' | node_modules/.bin/restructured 
/.../node_modules/restructured/lib/Parser.js:5
 */"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function peg$subclass(child,parent){function ctor(){this.constructor=child;}ctor.prototype=parent.prototype;child.prototype=new ctor();}function peg$SyntaxError(message,expected,found,location){this.message=message;this.expected=expected;this.found=found;this.location=location;this.name="SyntaxError";if(typeof Error.captureStackTrace==="function"){Error.captureStackTrace(this,peg$SyntaxError);}}peg$subclass(peg$SyntaxError,Error);peg$SyntaxError.buildMessage=function(expected,found){var DESCRIBE_EXPECTATION_FNS={literal:function literal(expectation){return"\""+literalEscape(expectation.text)+"\"";},"class":function _class(expectation){var escapedParts="",i;for(i=0;i<expectation.parts.length;i++){escapedParts+=expectation.parts[i]instanceof Array?clas

TypeError: Elements.InterpretedText is not a constructor
    at peg$c204 (/.../node_modules/restructured/lib/Parser.js:5:15685)
    at peg$parseInterpretedText (/.../node_modules/restructured/lib/Parser.js:5:113786)
    at peg$parseInlineMarkup (/.../node_modules/restructured/lib/Parser.js:5:97357)
    at peg$parseParagraphBlock (/.../node_modules/restructured/lib/Parser.js:5:146266)
    at peg$parseParagraph (/.../node_modules/restructured/lib/Parser.js:5:144478)
    at peg$parseBodyElementExceptBlockQuote (/.../node_modules/restructured/lib/Parser.js:5:66586)
    at peg$parseBodyElement (/.../node_modules/restructured/lib/Parser.js:5:66817)
    at peg$parseDocument (/.../node_modules/restructured/lib/Parser.js:5:37736)
    at Object.peg$parse [as parse] (/.../node_modules/restructured/lib/Parser.js:8:2638)
    at Object.parse (/.../node_modules/restructured/lib/RST.js:21:33)
seikichi commented 7 years ago

Hi @bgotink

Thank you for bug reporting, I fixed the problem and released version 0.0.9.

> echo 'Foo :ref:`bar`' | restructured
{"type":"document","children":[{"type":"paragraph","children":[{"type":"text","value":"Foo "},{"type":"interpreted_text","children":[{"type":"text","value":"bar"}],"role":"ref"},{"type":"text","value":"\n"}]}]}
> echo '`x` :y:`z` :a:b' | restructured | jq
{
  "type": "document",
  "children": [
    {      
      "type": "paragraph",
      "children": [
        {
          "type": "interpreted_text",
          "children": [
            {
              "type": "text",
              "value": "x"
            }
          ],
          "role": null
        },
        {
          "type": "text",
          "value": " "
        },
        {
          "type": "interpreted_text",
          "children": [
            {
              "type": "text",
              "value": "z"
            }
          ],
          "role": "y"
        },
        {
          "type": "text",
          "value": " :a:b\n"
        }
      ]
    }
  ]
}
bgotink commented 7 years ago

awesome, thanks!