Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is an error when trying to pass options as parse argument #2

Closed
marioosh opened this issue Jul 10, 2018 · 3 comments
Closed

There is an error when trying to pass options as parse argument #2

marioosh opened this issue Jul 10, 2018 · 3 comments

Comments

@marioosh
Copy link

marioosh commented Jul 10, 2018

let options: MarkedOptions = {isNoP: true};

Marked.setOptions(options);//is working but

Marked.parse("some intput", options)//provides to error:

TypeError: this.options.escape is not a function
Please report this to https://github.com/KostyaTretyak/marked-ts
    at InlineLexer.output (http://localhost:8100/build/vendor.js:74738:56)
    at Parser.parseText (http://localhost:8100/build/vendor.js:74372:33)
    at Parser.tok (http://localhost:8100/build/vendor.js:74387:37)
    at Parser.parse (http://localhost:8100/build/vendor.js:74345:25)
    at Function.Parser.parse (http://localhost:8100/build/vendor.js:74338:23)
    at Function.Marked.callParser (http://localhost:8100/build/vendor.js:50612:36)
    at Function.Marked.parse (http://localhost:8100/build/vendor.js:50558:25)
    at MarkedProvider.webpackJsonp.214.MarkedProvider.simpleMarked (http://localhost:8100/build/main.js:162:66)
....
@KostyaTretyak
Copy link
Collaborator

  • Marked.setOptions(options) makes merge with default options.
  • Second parameter for Marked.parse("some intput", options) apply your options without merge with default options.

Try just:

let options: MarkedOptions = {isNoP: true};
Marked.setOptions(options);
Marked.parse("some intput");

@marioosh
Copy link
Author

Agree, but I have two functions one with options second without, and have at the beginning of each call Marked.setOptions. It would be better to make possible use temporary options only for parsing..
Btw. I workarounded it, but reported this issue as bug.

@KostyaTretyak
Copy link
Collaborator

KostyaTretyak commented Jul 11, 2018

@marioosh, you can get all default options when call new MarkedOptions:

import { Marked, MarkedOptions } from 'marked-ts';

const options1 = new MarkedOptions;
options1.isNoP = true;
const html1 = Marked.parse("some intput", options1);

const options2 = new MarkedOptions;
options2.isNoP = false;
const html2 = Marked.parse("some intput", options2);

console.log(html1); // some intput
console.log(html2); // <p>some intput</p>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants