nightwatchjs / nightwatch-docs

Source for https://nightwatchjs.org website
https://nightwatchjs.org
MIT License
95 stars 197 forks source link

Custom Runner Example underscores stripped in rendered output #102

Open cdunklau opened 5 years ago

cdunklau commented 5 years ago

The custom runner example under Programmatic API fails when copy-pasted from the website:

const Nightwatch = require('nightwatch');

// read the CLI arguments
Nightwatch.cli(function(argv) {
  argv.source = argv[''].slice(0);

  // create the Nightwatch CLI runner
  const runner = Nightwatch.CliRunner(argv);

  // setup and run tests
  runner
    .setup()
    .startWebDriver()
    .then(() => runner.runTests())
    .then(() => runner.stopWebDriver())
    .catch(err => console.error(err));
});

Output:

/path/to/copypasted.js:5
  argv.source = argv[''].slice(0);
                         ^

TypeError: Cannot read property 'slice' of undefined
    at /path/to/copypasted.js:5:26
<snip>

But it works when copying from markdown source directly:

const Nightwatch = require('nightwatch');

// read the CLI arguments
Nightwatch.cli(function(argv) {
  argv._source = argv['_'].slice(0);

  // create the Nightwatch CLI runner
  const runner = Nightwatch.CliRunner(argv);

  // setup and run tests
  runner
    .setup()
    .startWebDriver()
    .then(() => runner.runTests())
    .then(() => runner.stopWebDriver())
    .catch(err => console.error(err));
});

Notice the difference on line 5, there are two underscores in the markdown source that appear to be stripped at some point during the HTML rendering process. Github's render of the file also shows the source = argv[ part in italics, so it looks like there might be a more widespread problem with handling underscores in markdown things that use <pre> and/or <code> for code blocks.

(edit: I just looked at the HTML source of the website instead of the inspector, and found that your markdown renderer indeed sticks an <em> in there, at the same place that Github's does: argv.<em>source = argv[&#39;</em>&#39;].slice(0);)

I would be glad to help isolate and fix this, but I haven't been able to find the environment used to actually render these docs for the website. Maybe consider adding that to this repo? It would be nice for people to be able to contribute formatting fixes, and in general be able to see the results of their contributions locally.

beatfactor commented 5 years ago

Thanks for reporting this, we'll address it for the next release.