attakei / sphinx-revealjs

HTML Presentation builder for Pythonista
https://attakei.github.io/sphinx-revealjs/
Apache License 2.0
110 stars 20 forks source link

Initialize is failure when `revealjs_script_conf` includes quoted string #154

Closed attakei closed 11 months ago

attakei commented 11 months ago

Desciption

When revealjs_script_conf uses string-type parameter and parameter includes quote charecters, it builds successfully but it does not render as presentation. (See reproduction)

Reproduction

Build revealjs or dirrevealjs with this parameters in conf.py

revealjs_script_conf = {
    "controls": True,
    "progress": True,
    "hash": True,
    "center": True,
    "transition": "slide",
    "dummy": "This is \"quoted\"",
}

Actually

Object.assign(
  revealjsConfig,
  JSON.parse('{"controls": true, "progress": true, "hash": true, "center": true, "transition": "slide", "dummy": "This is 'quoted'", "scrollActivationWidth": null}')
);

This script is not working, console raises Uncaught SyntaxError: missing ) after argument list.

Expected

Object.assign(
  revealjsConfig,
  JSON.parse('{"controls": true, "progress": true, "hash": true, "center": true, "transition": "slide", "dummy": "This is \'quoted\'", "scrollActivationWidth": null}')
);

Single-quote in string must be escaped.

attakei commented 11 months ago

When parameter includes double-quote , raise error in same point.

Code

revealjs_script_conf = {
    "controls": True,
    "progress": True,
    "hash": True,
    "center": True,
    "transition": "slide",
    "dummy": "This is \"quoted\"",
}

Actually

Object.assign(
  revealjsConfig,
  JSON.parse('{"controls": true, "progress": true, "hash": true, "center": true, "transition": "slide", "dummy": "This is \"quoted\"", "scrollActivationWidth": null}')
);

This script is not working, console raises Uncaught SyntaxError: Expected ',' or '}' after property value in JSON at position XXX.

Expected

Object.assign(
  revealjsConfig,
  JSON.parse('{"controls": true, "progress": true, "hash": true, "center": true, "transition": "slide", "dummy": "This is \\"quoted\\"", "scrollActivationWidth": null}')
);
attakei commented 11 months ago

Fixe by v2.9.2