The script for this week is going to be another request by a customer. It is a good example of how to search for patterns in HTML and replace the content matching that pattern. A common task when converting an HTML document is trying to get indented paragraphs to indent at the same level. This is especially problematic when the document contains numbered paragraphs that are not hanging (such as a legal outline.) Dealing with this case isn’t exactly trivial in HTML, as it often imports with a set number of non-breaking spaces to create the indent. Unless you’re using a monospace font, the text will not perfectly align, and the outline will not look the same for every number. The best solution is to remove the non-breaking spaces, and wrap the lead-in text (the “(a)”, or “1.”, or “Section 1.”, etc) with a inline tag, using the display type “inline-block”. This, combined with a fixed width and “nowrap” properties, allows us to add a block of space that is a fixed width into a paragraph, so our lead-in text takes up exactly the right amount of space.
Continue reading "LDC #41: Align Outline Text" »