
Fixing codeboxes
- joedf
- Posts: 7859
- Joined: 29 Sep 2013, 17:08
- Facebook: J0EDF
- Google: +joedf
- GitHub: joedf
- Location: Canada
- Contact:
Re: Fixing codeboxes
Great to hear! 






Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x8GB G.Skill RipJaws V - DDR4 3280 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
- joedf
- Posts: 7859
- Joined: 29 Sep 2013, 17:08
- Facebook: J0EDF
- Google: +joedf
- GitHub: joedf
- Location: Canada
- Contact:
Re: Fixing codeboxes
another update, I've added the option to toggle line numbers 
Code here for future reference:

Code here for future reference:
Code: Select all
// joedf: add option toggle line numbers in codeboxes
// created Jan 2020
// should on all latest major browsers
// Chrome v1, Edge 12, FF62, IE9
function toggleLineNums_init(){
// add css rules
var ir = document.createElement('style');
ir.innerHTML = ".Ln_prism_sub::selection{background:none}" + "\n .Ln_prism_sub{width:auto;height:'+hCode+'px;float:left;border-right:1px solid limegreen;line-height:1.5em;padding-right:.5em;margin-right:.5em;text-align:right;color:#999;user-select:none;overflow:hidden;pointer-events:none}";
document.body.appendChild(ir);
// add toggle anchor links ...
var boxes = document.getElementsByTagName('code');
for (var i = 0; i < boxes.length; i++) {
var tagP = (boxes[i].parentNode.tagName.toLowerCase() == 'pre' ? boxes[i].parentNode.previousSibling : boxes[i].previousSibling);
tagP.innerHTML += ' - <a href="#" title="Toggle Line numbers" onclick="toggleLineNums(this); return false;">Toggle Line numbers</a>';
}
}
function toggleLineNums(e) {
var eCode = e.parentNode.parentNode.getElementsByTagName('code')[0];
// check if linenumbers are ready
if(eCode.className.indexOf('Ln_prism_ready')>-1) {
var lnBox = eCode.getElementsByClassName('Ln_prism_sub')[0];
// determine case to show/hide them
if(eCode.className.indexOf('Ln_prism_show')>-1) {
eCode.className = eCode.className.replace(' Ln_prism_show','')
lnBox.style.display = 'none';
} else {
eCode.className += ' Ln_prism_show';
lnBox.style.display = 'block';
}
} else {
// otherwise initialize and create the line numbers
var hCode = eCode.scrollHeight;
var l_start = '<div class="Ln_prism_sub">';
var l_end = '</div>';
var lnBox = window.document.createElement('div');
var numbers = [];
var hay = eCode.innerHTML;
var ln = 1;
for(var i=0;i<hay.length;i++){
if (hay[i]=='\n')
numbers.push(ln++);
}
numbers.push(ln++);
lnBox.innerHTML = l_start + numbers.join('\n') + l_end;
lnBox.style.display = 'block';
eCode.insertBefore(lnBox, eCode.firstChild);
eCode.className += ' Ln_prism_ready Ln_prism_show'
}
}
toggleLineNums_init();





Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x8GB G.Skill RipJaws V - DDR4 3280 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
- joedf
- Posts: 7859
- Joined: 29 Sep 2013, 17:08
- Facebook: J0EDF
- Google: +joedf
- GitHub: joedf
- Location: Canada
- Contact:
Re: Fixing codeboxes
Thanks! 






Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x8GB G.Skill RipJaws V - DDR4 3280 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Fixing codeboxes
I got into a real mess trying to use a saved draft.
Codebox stuff out the wazoo, in and out of my simple Help request.
Hope this helps your diagnosis.
Codebox stuff out the wazoo, in and out of my simple Help request.
Hope this helps your diagnosis.
- joedf
- Posts: 7859
- Joined: 29 Sep 2013, 17:08
- Facebook: J0EDF
- Google: +joedf
- GitHub: joedf
- Location: Canada
- Contact:
Re: Fixing codeboxes
@AreaMan
If you are having bugs or other issues with the codeboxes, please share the BBCode if possible. Thanks.
If you are having bugs or other issues with the codeboxes, please share the BBCode if possible. Thanks.






Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x8GB G.Skill RipJaws V - DDR4 3280 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Populate the AHK MiniCity!] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: Fixing codeboxes
You should also describe your exact work process... if I look at this: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=73586 , I see <br> tags (among others):
Code: Select all
<r>I have a bunch of simple hotkeys to insert commonly used text. No easy way to insert an em-dash so I tried AutoHotKey. Got strange results: [b]—[/b]<br/>
<br/>
Using the numeric Unicode finally worked.<br/>
<CODEBOX codebox="autohotkey" file="Untitled.ahk"><s>[Codebox=autohotkey file=Untitled.ahk]</s><i>
</i>^#e::
; ;; Control Window e yields an EM DASH: —
SendInput, {U+2014}
Return
^#g::
; ;; Control Window g yields — (Crap instead of an EM DASH)
SendInput, —
Return
<e>[/Codebox]</e></CODEBOX>
So why won't the em-dash itself insert like any other bunch of text?<br/>
<br/>
Windows 1909, 64-bit, x86<br/>
AutoHotKey 1.1.32.00</r>
Or did you somehow save your draft in HTML format yourself instead of using the built-in 'Save draft' function of the editor?
I actually don't think that those <r>, <s> or <e> tags will be created by the forum editor - and it doesn't look like our HTML source code either. I've used the forum editor's Save draft function regularly, but never encountered this. So, how is your process and does it also happen, if you don't use drafts?
Who is online
Users browsing this forum: No registered users and 2 guests