diff --git a/build.js b/build.js index 0f133cb..be0e700 100644 --- a/build.js +++ b/build.js @@ -516,7 +516,13 @@ const Builder = function(outBaseDir, options) { } function isRelative(url) { - return !url.startsWith('#') && !url.startsWith('/') && !url.includes('://'); + return !url.startsWith('#') && + !url.startsWith('/') && + !url.includes('://'); + } + + function isArticleLink(url) { + return !url.includes('/') && url.endsWith('.html'); } // Try top fix relative links. This *should* only @@ -543,7 +549,7 @@ const Builder = function(outBaseDir, options) { //const basedir = path.dirname(contentFileName); // console.log('---> pageUrl:', pageUrl); function fixRelLink(m, prefix, url, suffix) { - if (isSameDomain(url, pageUrl) && isRelative(url)) { + if (isSameDomain(url, pageUrl) && isRelative(url) && !isArticleLink(url)) { // a link that starts with "../" should be "../../" if it's in a translation // a link that starts with "resources" should be "../resources" if it's in a translation //const testName = path.join(basedir, url); diff --git a/test/expected/test/lessons/ja/test-one.html b/test/expected/test/lessons/ja/test-one.html index dce64dc..73ef68f 100644 --- a/test/expected/test/lessons/ja/test-one.html +++ b/test/expected/test/lessons/ja/test-one.html @@ -68,7 +68,11 @@

Article One

This is a foo bar foo test -and another

foo bar foo
grr.

+and another
foo bar foo
grr. +Link to another article. +Link to absolute article. +Link to back resource. +Link to forward resource.

<div>test *abc*<div>
 
diff --git a/test/expected/test/lessons/test-one.html b/test/expected/test/lessons/test-one.html index 01601ae..b93ff9a 100644 --- a/test/expected/test/lessons/test-one.html +++ b/test/expected/test/lessons/test-one.html @@ -68,7 +68,11 @@

Article One

This is a foo bar foo test -and another

foo bar foo
grr.

+and another
foo bar foo
grr. +Link to another article. +Link to absolute article. +Link to back resource. +Link to forward resource.

<div>test *abc*<div>
 
diff --git a/test/lessons/ja/test-one.md b/test/lessons/ja/test-one.md index 4a867ab..a2405e0 100644 --- a/test/lessons/ja/test-one.md +++ b/test/lessons/ja/test-one.md @@ -4,6 +4,10 @@ TOC: First Article This is a foo *bar* foo test and another
foo *bar* foo
grr. +Link to [another article](article.html). +Link to [absolute article](/absoute-article.html). +Link to [back resource](../resource/back.jpg). +Link to [forward resource](resource/forward.jpg). ```html
test *abc*
diff --git a/test/lessons/test-one.md b/test/lessons/test-one.md index 4a867ab..a2405e0 100644 --- a/test/lessons/test-one.md +++ b/test/lessons/test-one.md @@ -4,6 +4,10 @@ TOC: First Article This is a foo *bar* foo test and another
foo *bar* foo
grr. +Link to [another article](article.html). +Link to [absolute article](/absoute-article.html). +Link to [back resource](../resource/back.jpg). +Link to [forward resource](resource/forward.jpg). ```html
test *abc*