Skip to content

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

Description

@ProditorMagnus

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);
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions