wesnoth / wesmere

Website design for The Battle for Wesnoth used since mid-July 2017.
https://www.wesnoth.org/
Other
7 stars 8 forks source link

Select all button of <syntaxhighlight lang=lua line> includes line number in text #27

Open ProditorMagnus opened 3 months ago

ProditorMagnus commented 3 months ago

https://wiki.wesnoth.org/Sandbox/GUI/Getting_Started#Building_a_Tree uses <syntaxhighlight lang=lua line>, and clicking it selects

  1local function basic_tree_view()
  2    local tree_view = wml.tag.tree_view {
  3        id = "monsters_tv",
  4   ...

Expected behaviour would be excluding line numbers. Proof of concept solution (chrome):

$(".cb-icon").click(function(event) {
    var e = $(this).parents(".codebox").children("pre")[0];

    let textResult = "";
    for (node of e.childNodes){
        if(typeof node.getAttribute !== "function" || node.getAttribute("class") !== "linenos"){
            let currentText = node.innerText || node.nodeValue;
            if (currentText) {
                textResult += currentText;
            }
        }
    }
    navigator.clipboard.writeText(textResult);
});
soliton- commented 1 month ago

I do not get line numbers in the copied text in either chrome, firefox or safari.

ProditorMagnus commented 1 month ago

I believe @celticminstrel fixed it soon after I reported it

CelticMinstrel commented 1 month ago

I fixed it by editing the Common.css page on the wiki. There might be a better fix in the style itself.