Skip to content

Commit 87c277a

Browse files
committed
Version 0.3.4
Added Colour & Started work on theming Work on Syntax Highlighting in Markdown Preliminary work on virtual documents and Slideshows Markdown now supports Heading 3 for selection.
1 parent e4d0eac commit 87c277a

12 files changed

+197
-57
lines changed

.DS_Store

6 KB
Binary file not shown.

README.css

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
/* Layout
24
================================================ */
35
html {
@@ -16,7 +18,7 @@
1618
body {
1719
font-family: "Source Sans Pro";
1820
font-size: 1em;
19-
--color: #2A5F5B;
21+
--color: #204564;
2022
}
2123
code {
2224
font-family: "Source Code Pro";

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
<link rel="stylesheet" href="README.css">
12
<style>
3+
@import 'README.css';
24
th, td {
35
text-align: left;
46
vertical-align: top;
@@ -8,7 +10,7 @@
810
tab-size: 4 !important;
911
}
1012
</style>
11-
# Document Pager 0.3.3
13+
# Document Pager 0.3.4
1214

1315
Document Pager © Mark Simon
1416
https://github.com/manngo/document-pager

compile.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# rm -rf ../release-builds/Document\ Pager*;
2-
2+
npx electron-builder build
33
# electron-packager . --overwrite --platform=darwin --arch=x64 --prune=true --extend-info "info.plist" --out="../release-builds/" # --icon ./images/edit-virtual-hosts.icns;
44
electron-packager . --overwrite --platform=darwin --arch=x64 --prune=true --out="../release-builds/" # --icon ./images/edit-virtual-hosts.icns;
55
# electron-packager . --overwrite --platform=win32 --arch=x64 --prune=true --out="../release-builds" # --icon images/edit-virtual-hosts.ico;

data/about.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## About Text Pager 0.3.3
1+
## About Text Pager 0.3.4
22

33
Text Pager © Mark Simon
44
See also https://pager.internotes.net/

index.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ <h1>Document Pager</h1>
3232
-->
3333
<p><input type="checkbox" name="show-highlight" id="control-show-highlight" checked><label for="control-show-highlight">Show Highlighted</label></p>
3434
<hr>
35-
<p id="font-size"><button type="button" name="zoom-smaller">-</button><button type="button" name="zoom-default"></button><button type="button" name="zoom-larger">+</button></p>
35+
<p id="font-size"><!-- ▼▲✚ -->
36+
<button type="button" name="zoom-smaller" id="control-zoom-smaller">-</button><label for="control-zoom-smaller">⬇︎</label>
37+
<button type="button" name="zoom-default" id="control-zoom-default"></button><label for="control-zoom-default">◼︎</label>
38+
<button type="button" name="zoom-larger" id="control-zoom-larger">+</button><label for="control-zoom-larger">⬆︎</label>
39+
</p>
3640
<p><input type="checkbox" name="show-documents" id="control-show-documents" checked><label for="control-show-documents">Documents</label></p>
3741
<!--
3842
<label for="upload-file">Open or Drop File …</label><input type="file" name="upload" id="upload-file">
3943
-->
40-
<p><button type="button" name="full-screen">Full Screen</button></p>
44+
<p><button type="button" name="full-screen" id="control-full-screen">Full Screen</button><label for="control-full-screen">Full Screen</label></p>
4145
</form>
4246
</header>
4347
<aside id="about" data-load="/content/about.html"></aside>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "document-pager",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Document Pager: Displays a text document in tabbed pages.",
55
"main": "main.js",
66
"repository": "https://github.com/manngo/document-pager",

scripts/pager.js

+52-13
Original file line numberDiff line numberDiff line change
@@ -453,23 +453,24 @@
453453
fs.stat
454454
================================================ */
455455

456-
function addDocument(text,language,fileName,path,css) {
456+
function addDocument(text,language,fileName,path,css,extension) {
457457
var tab=document.createElement('li');
458458
// var css='';
459459
tab.textContent=fileName;
460460
// if(language=='markdown') var css=`${path}/${fileName.replace(/\..*$/,'')}/styles.css`;
461461

462-
tab.data={text, language, fileName, path, item: 0, highlighted: 1 , css};
462+
tab.data={text, language, fileName, path, item: 0, highlighted: 1 , css,extension};
463463
tab.onclick=doTab;
464464

465465
var close=document.createElement('button');
466-
close.innerHTML=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="8" height="8" viewBox="0, 0, 24, 24"><path d="M3.141,24 L-0,24 L10.332,11.935 L-0,0 L3.401,0 L12,9.06 L20.924,0 L24,0 L13.581,11.935 L24,24 L20.664,24 L12,14.33 z" fill="#000000"/></svg>`; // '⨉'; // ✖️
466+
// close.innerHTML=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="8" height="8" viewBox="0, 0, 24, 24"><path d="M3.141,24 L-0,24 L10.332,11.935 L-0,0 L3.401,0 L12,9.06 L20.924,0 L24,0 L13.581,11.935 L24,24 L20.664,24 L12,14.33 z" fill="#000000"/></svg>`; // '⨉'; // ✖️
467+
close.innerHTML='×';
467468
close.onclick=closeTab.bind(tab,tab);
468-
close.id='tab-close';
469+
close.className='tab-close';
469470
var refresh=document.createElement('button');
470471
refresh.innerHTML='↻';
471472
refresh.onclick=refreshTab.bind(tab);
472-
refresh.id='tab-refresh';
473+
refresh.className='tab-refresh';
473474

474475
// Add to DOM
475476
tab.appendChild(close);
@@ -641,7 +642,7 @@
641642
if(!title.length) return;
642643

643644
li.insertAdjacentHTML('beforeend',`<span>${title}</span>`);
644-
if(value.match(headingMiniscule)) li.classList.add('subtitle');
645+
if(data.language=='markdown' && value.match(headingMiniscule)) li.classList.add('subtitle');
645646
li.next=li.previous=undefined;
646647
if(previous) {
647648
previous.next=li;
@@ -669,8 +670,6 @@
669670
if(!selected) selected=li;
670671
});
671672

672-
673-
674673
if(selected) selected.click();
675674
}
676675
else showItem(data.text,data.fileName,true);
@@ -707,7 +706,7 @@
707706
var language=['js','javascript','sql','php'].indexOf(data.language)>-1;
708707
elements.codeElement.textContent=item;
709708

710-
elements.codeElement.classList.forEach(className=>{if(className.startsWith('language-')) elements.codeElement.classList.remove(className);});
709+
elements.codeElement. classList.forEach(className=>{if(className.startsWith('language-')) elements.codeElement.classList.remove(className);});
711710
elements.codeElement.classList.add(`language-${data.language}`);
712711
lineNumbers.style.display='block';
713712
elements.codeElement.style.display='block';
@@ -732,6 +731,17 @@
732731

733732
div.innerHTML=innerHTML;
734733

734+
// var doEtc = false; if(doEtc)
735+
div.querySelectorAll('pre').forEach(pre=>{
736+
var code = pre.querySelector('code');
737+
// var codeDiv = document.createElement('div');
738+
var html = code.innerHTML.replace(/ /g,'\t');
739+
var language = code.className.match(/\blanguage-(.*)\b/)[1];
740+
code.innerHTML=Prism.highlight(html, Prism.languages[language], language);
741+
// codeDiv.innerHTML=Prism.highlight(html, Prism.languages[language], language);
742+
// lineNumbers=jx.addLineNumbers(codeDiv);
743+
// code.parentNode.replaceChild(codeDiv,code);
744+
});
735745

736746
var h2=div.querySelector('h1,h2,h3');
737747
// var h2=div.querySelector('h2');
@@ -766,7 +776,6 @@
766776
},false);
767777
});
768778

769-
770779
lineNumbers.style.display='none';
771780
elements.codeElement.style.display='none';
772781
elements.mdElement.style.display='block';
@@ -837,14 +846,44 @@ console.log(fileName);
837846
else result=openPath(fileName,remember);
838847
return result;
839848

849+
function virtualDocument(pathName) {
850+
var {path,fileName,extension,css}=pathDetails(pathName);
851+
fsp.stat(pathName)
852+
.then(()=>{
853+
console.log(pathName);
854+
return load(`${path}/${fileName}`);
855+
})
856+
.then(data=>{
857+
data=JSON.parse(data);
858+
var md=[];
859+
fetch(data.data.url)
860+
.then(response=>{
861+
console.log(response);
862+
return response.json();
863+
})
864+
.then(images=>{
865+
images.forEach(image=>{
866+
md.push(`#\t${image.title}`);
867+
md.push(`![${image.title}](https://javascript101.webcraft101.com/images/slides/${image.src})`);
868+
});
869+
data = md.join('\n\n');
870+
addDocument(data,extensions['md'],fileName,path,'','md');
871+
});
872+
873+
// doSlides(images,'div#slides');
874+
});
875+
}
876+
840877
function openPath(pathName,remember=false) {
878+
var {path,fileName,extension,css}=pathDetails(pathName);
879+
if(extension=='dpf') return virtualDocument(pathName);
841880
return fsp.stat(pathName)
842881
.then(()=>{
843-
var {path,fileName,extension,css}=pathDetails(pathName);
882+
// var {path,fileName,extension,css}=pathDetails(pathName);
844883
return fsp.stat(css).catch(()=>css='')
845884
.then(()=>load(`${path}/${fileName}`))
846885
.then(data=> {
847-
addDocument(data,extensions[extension],fileName,path,css);
886+
addDocument(data,extensions[extension],fileName,path,css,extension);
848887
})
849888
.then(()=>{
850889
updateDocuments();
@@ -905,7 +944,7 @@ console.log(fileName);
905944
})
906945
.then((text)=>{
907946
if(cancelled) return;
908-
addDocument(data,extensions[extension],fileName,path,css);
947+
addDocument(data,extensions[extension],fileName,path,css,extension);
909948
})
910949
.then(()=>{
911950
if(cancelled || !remember) return;

scripts/utilities.js

-4
Original file line numberDiff line numberDiff line change
@@ -731,13 +731,9 @@
731731
var lines=element.textContent.split(/\r?\n/).length;
732732
lineNumbers.textContent=Array.from({length: lines},(v,i)=>i+1).join('\n');
733733

734-
735-
736734
var styles=['line-height','font-family','padding-top','padding-bottom','font-size'];
737735
var computedStyles=window.getComputedStyle(element);
738736
styles.forEach(style=>lineNumbers.style[style]=computedStyles[style]);
739-
740-
741737
};
742738
return lineNumbers;
743739
};

settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.3.3",
2+
"version": "0.3.4",
33
"headings": {
44
"title": "Document Pager",
55
"h1": "Document Pager",

styles/content.css

+8-1
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,32 @@
5656
/* Prism
5757
================================================ */
5858

59+
div#md>div>pre>code[class*="language-"],
5960
div#main-content>code[class*="language-"] {
6061
background-color: white;
6162
}
6263

64+
div#md>div>pre>code,
6365
div#main-content code {
6466
height: calc(100vh - 1rem);
6567
}
6668

69+
div#md>div>pre>code .token.tab,
70+
div#md>div>pre>code .token.crlf,
71+
div#md>div>pre>code .token.lf,
72+
div#md>div>pre>code .token.cr,
6773
div#main-content .token.tab,
6874
div#main-content .token.crlf,
6975
div#main-content .token.lf,
7076
div#main-content .token.cr {
7177
visibility: hidden;
7278
}
7379

80+
div#md>div>pre>code[class*="language-"],
7481
div#main-content>code[class*="language-"] {
7582
font-family: "Source Code Pro", monospace;
7683
font-size: .8em;
77-
padding: .5em 0;
84+
qpadding: .5em 0;
7885
line-height: 1.5;
7986
}
8087

0 commit comments

Comments
 (0)