@bbc/morty-docs 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,13 +4,17 @@ const showdown = require('showdown'); // there may be an option to enable this,
4
4
 
5
5
  const convertMdLinksToHtmlLinks = {
6
6
  type: 'output',
7
- regex: /<a href="([^:\n]*).md">/g,
7
+ regex: /<a href="([^:\n]*?).md">/g,
8
8
  // exclude colon, so external links aren't converted
9
9
  replace: '<a href="$1.html">'
10
- }; // Due to the converter the global replace on links is broken so if you have multiple links per line we need multiple matchers or they don't get replaced.
10
+ }; // Replace hash links with .html e.g. page.md#Title becomes page.html#Title.
11
11
 
12
- const maxLinksPerLine = 10;
13
- const convertMultipleMdLinksToHtmlLinks = new Array(maxLinksPerLine).fill().map(x => convertMdLinksToHtmlLinks);
12
+ const convertMdHashLinksToHtmlLinks = {
13
+ type: 'output',
14
+ regex: /<a href="([^:\n]*?).md#(.*?)">/g,
15
+ // exclude colon, so external links aren't converted
16
+ replace: '<a href="$1.html#$2">'
17
+ };
14
18
  const headingExtension = {
15
19
  type: 'output',
16
20
  regex: /<(h[123456]) id="(.*)">(.*)<\/\1>/g,
@@ -45,7 +49,7 @@ const createParser = options => {
45
49
  replace: `<a href="${basePath}/$1">`
46
50
  };
47
51
  const parser = new showdown.Converter({
48
- extensions: [convertMultipleMdLinksToHtmlLinks, addBasePathToRootLinks, headingExtension, ...bindings]
52
+ extensions: [convertMdLinksToHtmlLinks, convertMdHashLinksToHtmlLinks, addBasePathToRootLinks, headingExtension, ...bindings]
49
53
  });
50
54
  parser.setFlavor('github');
51
55
  return parser;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbc/morty-docs",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "To generate a static website from markdown documentation, to allow users to consume content in an easily accessible format",
5
5
  "main": "build/index.js",
6
6
  "publishConfig": {