Skip to content

Commit

Permalink
Much fixing of stuff. Some of it successful! More work on KeywordsE.
Browse files Browse the repository at this point in the history
  • Loading branch information
NormanDunbar committed Aug 11, 2016
1 parent ba7b8bd commit 643e351
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 74 deletions.
14 changes: 14 additions & 0 deletions arrows.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Arrows</title>
</head>
<body>
<ul>
<li>Lefty &LeftArrow;</li>
<li>Right &RightArrow;</li>
<li>Up &UpArrow;</li>
<li>Down &DownArrow;</li>
</ul>
</body>
</html>

4 changes: 4 additions & 0 deletions arrows.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Lefty ←
- Right →
- Up ↑
- Down ↓
12 changes: 6 additions & 6 deletions errors/KeywordsE.errors.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
line 364 column 184 - Warning: trimming empty <span>
line 364 column 328 - Warning: trimming empty <span>
line 383 column 184 - Warning: trimming empty <span>
line 383 column 328 - Warning: trimming empty <span>
line 1440 column 74 - Warning: trimming empty <span>
line 1443 column 168 - Warning: trimming empty <span>
line 370 column 184 - Warning: trimming empty <span>
line 370 column 328 - Warning: trimming empty <span>
line 391 column 184 - Warning: trimming empty <span>
line 391 column 328 - Warning: trimming empty <span>
line 1522 column 74 - Warning: trimming empty <span>
line 1525 column 168 - Warning: trimming empty <span>
Info: Doctype given is "-//W3C//DTD HTML 4.0 Transitional//EN"
Info: Document content looks like HTML 4.01 Strict
Info: No system identifier in emitted doctype
Expand Down
173 changes: 120 additions & 53 deletions sphinx/source/KeywordsE.clean.rst

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion tools/HTMLTidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

DIR=`dirname "${0}"`
HTML="${1}"
TMP=${HTML}.tmp
CLEAN="${HTML%%html}clean.html"
ERRS="${HTML%%html}errors.txt"
CHECK=0

# Clean up first...
# PreClean...
preHTMLTidy < ${HTML} > ${TMP}

echo "Cleaning '${HTML}' as '${CLEAN}', with errors in '${ERRS}'"
tidy -indent -wrap 1000 -upper -ashtml -utf8 -file "${ERRS}" -output "${CLEAN}" "${HTML}"
tidy -indent -wrap 1000 -upper -ashtml -utf8 -file "${ERRS}" -output "${CLEAN}" "${TMP}"
CHECK=${?}

# 1 = Warnings
Expand Down Expand Up @@ -42,6 +46,8 @@ then
exit $?
fi

# Finished with ${TMP}
#rm ${TMP} 2>/dev/null

# All done. Sort of. Need to go manual now.
echo "Done."
Expand Down
4 changes: 2 additions & 2 deletions tools/fixSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void doSyntax(const size_t pos)
// Read a few more lines. We shouldn't hit EOF here! (FLW!)
getline(cin, a_line);
posLocation = a_line.find("Location:", 0, 9);
if ((posLocation != string::npos) || (a_line.size() == 0)) {
if ((posLocation != string::npos) || (a_line.empty())) {
break;
} else {
buffer += (" " + a_line);
Expand Down Expand Up @@ -165,7 +165,7 @@ void doLocation(const size_t pos)
while (1) {
// Read a few more lines. We shouldn't hit EOF here! (FLW!)
getline(cin, a_line);
if (a_line.size() == 0) {
if (a_line.empty()) {
break;
} else {
buffer += (" " + a_line);
Expand Down
85 changes: 73 additions & 12 deletions tools/preHTMLTidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
//
// <br href="..."
//
// Whihc is wrongs. These should be:
// Which is wrong. These should be:
//
// <a href="..."
//
// These should be fixed before we get to HTMLTidy.sh.
//
// Once the above is fixed, we check for "Location:" and if found
// scan for the next closing </span> and make sure we have a blank line after it.
//

using std::string;
using std::getline;
Expand All @@ -32,23 +35,81 @@ int main (int argc, char *argv[])
{
// Read stdin until EOF
while (1) {
getline(cin, a_line);
getline(cin, a_line);

// Check for end of input.
if (cin.eof()) {
return 0;
}
// Check for end of input.
if (cin.eof()) {
return 0;
}

// Check for '<br href='
size_t pos = a_line.find("<br href=", 0, 9);

if (pos != string::npos) {
// We have it. Fix it.
a_line = a_line.substr(0, pos) + "<a href=" + a_line.substr(pos + 9, string::npos);
}

// Check for '<br href='
size_t pos = a_line.find("<br href=", 0, 9);
// We have fixed the faulty <a> tags, check for Location:
pos = a_line.find("Location:", 0, 9);

// Did we find it?
if (pos != string::npos) {
// See if </span> is on the same line.
pos = a_line.find("</span>", pos + 9, 7);
if (pos == string::npos) {
// Try upper case, just in case.
pos = a_line.find("</SPAN>", pos + 9, 7);
}

// Found? Write the current line up to the end of </span>
// then write a blank, followed by the rest of the line after the </span>
if (pos != string::npos) {
// We have it. Fix it.
a_line = a_line.substr(0, pos) + "<a href=" + a_line.substr(pos + 9, string::npos);
cout << a_line.substr(0, pos + 7) << endl << endl;

// Check we don't fall off the end.
if (pos + 7 <= a_line.size()) {
cout << a_line.substr(pos + 7, string::npos) << endl;
}

// Read and process the next line.
continue;
}

// Not found. Write out the whole line, then read and check again.
while (1) {
cout << a_line << endl;

getline(cin, a_line);

// Check for end of input.
if (cin.eof()) {
return 0;
}

pos = a_line.find("</span>", 0, 7);
if (pos == string::npos) {
pos = a_line.find("</SPAN>", 0, 7);
}

if (pos == string::npos) {
// Write out and loop.
continue;
}

// We finally have it!
// Write out with a blank after the </span>.
cout << a_line.substr(0, pos + 7) << endl << endl;

// Reset a_line ready for the break & write.
a_line = a_line.substr(pos + 7, string::npos);
break;
}

}

// Just write everything else out.
cout << a_line << endl;
// Finally write everything out.
cout << a_line << endl;
}
}

Expand Down

0 comments on commit 643e351

Please sign in to comment.