Skip to content

Commit

Permalink
Special Characters and Broken Links
Browse files Browse the repository at this point in the history
# Pull Summary
Special Characters and Links: 2 scripts added, and Makefile edited.

This pull request contains **"jhauga-resolveOptionLinks"** branch with:
1. Two supporting script files added that edit .dump file after 
nroff build. 
2. Makefile edited to run two supporting scripts after build. 
3. Example folder with proof of concept of support scripts used 
in Makefile.

## Branch Summary - jhauga-resolveOptionLinks
Files added/edited:
1. Makefile
   - Line 28 - \@.\/fixSpecialCharacters.sh
   - Line 29 - \@.\/fixBrokenLinks.sh
2. fixSpecialCharacters.sh
   - Prompts for input, asking if ther are options with special characters.
   - If so will run several "sed" statements to replace accordingly.
   - Provides additional variable (*commented out*) for custom generation.
3. fixBrokenLinks.sh
   - fixes encoded html characters rendered by noffit that cause broken links.
   - Voids (*javascript:coid(0)*) unwanted links.
4. examples_DELETE_ME
   - Example folder with proof of concept of supporting scripts used in Makefile.
   - For more details see **"README.md"** included in folder.

## Resolves
This pull request will resolve:
1. [roffit issue bagder#36](bagder#36)
2. [curl issue #11381](curl/curl#11381)
  • Loading branch information
jhauga authored Jul 8, 2023
1 parent 26d34eb commit 985a41f
Show file tree
Hide file tree
Showing 22 changed files with 23,294 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ install:

test:
@perl roffit --bare < testpage.1 > testpage.dump
@./fixSpecialCharacters.sh
@./fixBrokenLinks.sh
@if cmp testpage.dump testpage.output; then \
echo "SUCCESS"; \
else \
Expand Down
436 changes: 436 additions & 0 deletions examples_DELETE_ME/1.html

Large diffs are not rendered by default.

130 changes: 130 additions & 0 deletions examples_DELETE_ME/2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@

<!--_END_OUT-->
</div>
</div>
<script>
var setScroll = 0;
function showTop(clicked) {
if (clicked == undefined) clicked = 0;
let toTop = document.getElementById("toTop");
if (clicked == 1) toTop.style.display = "inline-block";
if (setScroll == 0) {
setScroll = 1;
document.addEventListener('scroll', function() {
if (document.documentElement.scrollTop > 500) {
toTop.style.display = 'inline-block';
} else {
toTop.style.display = 'none';
}
});
}
}
function showLink(curTask) {
var curhref;
if (curTask == "b") { curhref = "https://curl.se/docs/"; } else { curhref = "javascript:void(0)"; }
var aBrokenLink = document.getElementsByTagName('a');
var theBrokenLink = [], theBrokenLinkIndex = 0;
for (i = 0; i < aBrokenLink.length; i++) {
if (aBrokenLink[i].href == curhref) {
theBrokenLink[theBrokenLinkIndex] = aBrokenLink[i];
theBrokenLinkIndex++;
aBrokenLink[i].style.background = 'yellow';
aBrokenLink[i].style.border = '1px solid black';
aBrokenLink[i].style.padding = '2px';
}
}
setTimeout(function() {
for (i in theBrokenLink) {
if (theBrokenLink[i].style.background == "yellow") theBrokenLink[i].style.background = "";
}
}, 800);
setTimeout(function() {
for (i in theBrokenLink) {
theBrokenLink[i].style.border = '';
theBrokenLink[i].style.padding = '';
}
}, 1500);
}
function searchOptions(txt) {
let optionMenu = document.getElementById("optionMenu");
let optionMenuLi = optionMenu.getElementsByTagName("li");
for (i = 0; i < optionMenuLi.length; i++) {
let curLI = optionMenuLi[i].innerText;
if (curLI.indexOf(txt) > -1) {
optionMenuLi[i].style.display = "";
} else {
optionMenuLi[i].style.display = "none";
}
}
}
function toggleSearchButton(showhide, onoff) {
let showItem = showhide.nextElementSibling;
let curData = onoff.dataset;
if (curData.onoff == 0) {
curData.onoff = 1;
showItem.style.display = "";
onoff.style.background = "white";
onoff.style.color = "black";
onoff.innerHTML = onoff.innerHTML.replace("Show", "Hide");
} else {
curData.onoff = 0;
showItem.style.display = "none";
onoff.style.background = "";
onoff.style.color = "";
onoff.innerHTML = onoff.innerHTML.replace("Hide", "Show");
}
}
function addOptionLinks() {
let optionMenu = document.getElementById("optionMenu");
let optionMenuLi = optionMenu.getElementsByTagName("li");
let fullOptionList = document.getElementById("fullOptionList");
fullOptionList.style.display = "";
let i = 0;
while (i < 14) {
optionMenuLi[0].remove();
i++;
}
i = 0;
while (i < 4) {
optionMenu.children[0].remove();
i++;
}
optionMenuLi = fullOptionList.getElementsByTagName("li");
for (i = 0; i < optionMenuLi.length; i++) {
optionMenuLi[i].getElementsByTagName("a")[0].addEventListener("click", function() {
var hValue;
if (this.innerHTML.indexOf(",") > -1 || this.innerHTML.indexOf("&lt;") > -1) {
if (this.innerHTML.indexOf(",") > -1 && this.innerHTML.indexOf("&lt;") > -1) {
this.href = "#" + this.innerHTML.substr(0, this.innerHTML.indexOf(","));
} else {
if (this.innerHTML.indexOf(",") > -1 && this.innerHTML.indexOf("&lt;") == -1) { this.href = "#" + this.innerHTML.substr(0, this.innerHTML.indexOf(",")); }
else { this.href = "#" + this.innerHTML.substr(0,this.innerHTML.indexOf("&lt;")); }
}
hValue = this.href;
} else {
this.href = "#" + this.innerHTML;
hValue = this.href;
}
let hasSpace = 1;
while (hasSpace == 1) {
if (hValue.indexOf(" ") > -1) {
hValue = hValue.replace(" ", "");
} else {
hasSpace = 0;
}
}
if (hValue.indexOf("#-#") > -1 || hValue.indexOf("#-:") > -1) {
if (hValue.indexOf("#-#") > -1) { hValue = hValue.replace("#-#", "#--progress-bar"); }
else { hValue = hValue.replace("#-:", "#--next"); }
this.href = hValue;
} else {
this.href = hValue;
}
});
}
}
showTop();
addOptionLinks();
</script>
</body>
</html>
Loading

0 comments on commit 985a41f

Please sign in to comment.