Tag Archives: text

A Simple HTML Parser in JavaScript

The JavaScript code below, when run, prompts the user to enter some HTML text. When the “Parse” button is clicked, that text will be parsed into an instance of a class named “HTMLDocument”, which contains within it objects corresponding to … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

A Text Console in JavaScript

Below is a simple text console implemented in JavaScript. To see it in action, copy it into an .html file and open that file in a web browser that runs JavaScript. Or, for an online version, visit https://thiscouldbebetter.neocities.org/textconsole.html. Click on … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Text Layout and Justification on an HTML5 Canvas

The JavaScript code below, when run, will automatically split a simple poem across three different rectangles on an HTML5 canvas, and render the justified text. ┬áTo see it in action, copy it into an .html file and open that file … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Finding Differences Between Two Text Files in JavaScript

The code shown below implements a text file comparator/differencer in JavaScript. When the program runs, the user is presented with an interface to input two text strings. When the button is clicked, the program finds the differences (and commonalities) between … Continue reading

Posted in Uncategorized | Tagged , , , , | 4 Comments

Reading a String from a File in JavaScript

The code shown below reads the contents of a text file “Test.txt” into a string, and then displays that string in the web browser. To see the code in action, paste it into an .html file and open that file … Continue reading

Posted in Uncategorized | Tagged , , , , | 12 Comments

Loading, Editing, and Saving a Text File in HTML5 Using Javascript

The HTML and JavaScript code below makes use of some features of HTML5 (specifically the “Blob” object, the File API, and the “download” attribute of the “a” tag) to allow the user to load, edit, and save a text file … Continue reading

Posted in Uncategorized | Tagged , , , | 180 Comments