Skip to content

Commit

Permalink
Merge pull request #12 from hatmarch/master
Browse files Browse the repository at this point in the history
Add better support for ignoring query string replacement (v0.1.11)
  • Loading branch information
blues-man authored Jul 16, 2021
2 parents 33f6bd0 + 579a7a7 commit 26b3779
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ yarn.lock
.tool-versions

.vscode/

#MacOSX
.DS_Store
26 changes: 26 additions & 0 deletions preview-src/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Author Name
:!example-caption:
:!table-caption:
:page-pagination:
:USER: %USER%

image:multirepo-ssg.svg[Multirepo SSG,200,float=right]
Platonem complectitur mediocritatem ea eos.
Expand All @@ -31,6 +32,31 @@ I like %COLOR% color

Here is a link:index.html?USER=%USER%#liber-recusabo[link^] containing a query string item that should open to "Liber recusabo" in a new window

[#query-string-replacement-testing]
== Query String Replacement Testing

_If the `USER` query string has been set in the URL, then you should see it replaced (or not) below according to the text_

[.console-output]
[source,bash,subs="+macros,+attributes"]
----
This should show the USER substitution: {USER}
----

This should also show the USER substitution: `%USER%`

[.no-query-replace]
[.console-output]
[source,bash,noquery,subs="+macros,+attributes"]
----
This should not: pass:[%USER%]
----

And this also should not: [.no-query-replace]`%USER%`

You should see USER replacement here: %USER% but not here: [.no-query-replace]#%USER%#


== Cu solet

Nominavi luptatum eos, an vim hinc philosophia intellegebat.
Expand Down
3 changes: 3 additions & 0 deletions preview-src/ui-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ page:
- content: Link Testing
url: '/xyz/5.2/index.html#link-testing'
urlType: internal
- content: Query String Replacement Testing
url: '/xyz/5.2/index.html#query-string-replacement-testing'
urlType: internal
- content: Cu Solet
url: '/xyz/5.2/index.html#cu-solet'
urlType: internal
Expand Down
10 changes: 4 additions & 6 deletions src/js/07-userparams-behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ document.addEventListener('DOMContentLoaded', function () {
// refreshing links

function replaceParamsInNodes (node, key, value) {
if (node.parentElement) {
//console.log('Parent element %s', node.parentElement.nodeName)
if (node.parentElement.nodeName === 'code' ||
node.parentElement.nodeName === 'CODE') {
return
}
// Don't descend into any nodes that are children of the no-query-replace class
if ((typeof node.classList !== 'undefined') && (node.classList.contains('no-query-replace'))) {
return
}

if (node.nodeType === 3) {
var text = node.data
node.data = applyPattern(text, key, value)
Expand Down

0 comments on commit 26b3779

Please sign in to comment.