I'm working on a "Programming Patterns" web page to provide college students with code snippets in the assemble language of a simulated computer. I've written JavaScript code to select the innerHTML of an element and copy it to the clipboard. However, I want to add line numbers to the displayed code so that accompanying text can refer to them, but not copy the line numbers. That is, students should see this:
1. LDA label1
2. ADD label2
3. OUT
4. HLT
5. label1 DAT 15
6. label2 DAT 34
But what should go to the clipboard should be this:
LDA label1
ADD label2
OUT
HLT
label1 DAT 15
label2 DAT 34
I have something working that involves putting each code snippet into a table with the line numbers in Is there a better way to do this? We use cookies to ensure the best experience on our website. This includes analytics, personalization, and marketing purposes. Some cookies are essential for the website to function properly. By clicking "Accept", you consent to our use of cookies. You can read more about how we use cookies and how you can change your preferences in our Privacy Policy. cells and code in calls. It's ugly and preparing and maintaining the code snippets is going to be a chore.
Privacy & Cookie Consent