Skip to content

Commit

Permalink
Merged KeywordsE from working branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
NormanDunbar committed Aug 19, 2016
2 parents 231d09c + a813dd5 commit ee33c4e
Show file tree
Hide file tree
Showing 7 changed files with 760 additions and 416 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
847 changes: 598 additions & 249 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
206 changes: 58 additions & 148 deletions tools/fixSyntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
//
// Of course, sometimes Location: and Syntax: happen to be on the
// same line, which is, to be blunt, a bit of a bugger!
//
// So far I've seen the following:
//
// 1. Syntax: blah Location: Blah<eol>
//
// 2. Syntax: blah<eol>
// Location: Blah<eol>
//
// 3. Syntax: blah<eol>
// blah blah blah Location: Blah<eol>
//
// 4. Syntax: blah<eol>
// blah blah blah<eol>
// blah blah blah<eol>
// blah blah blah Location: Blah<eol>
//
// In any of the above, Location's line may or may not be followed by a blank.


using std::string;
using std::getline;
Expand All @@ -31,7 +49,8 @@ void doSyntax(const size_t pos);
void doLocation(const size_t pos);
void doBoth(const size_t posSyntax, const size_t posLocation);

string a_line;
string a_line; // Storage for each line, without a line feed.
string buffer; // Storage for entire Syntax: + Location: section, with linefeeds.

string tableSeparator =
"+----------+-------------------------------------------------------------------+";
Expand All @@ -51,161 +70,52 @@ int main (int argc, char *argv[])
size_t posSyntax = a_line.find("Syntax:", 0, 7);
size_t posLocation = a_line.find("Location:", 0, 9);

// Did we find both of them in one line?
if ((posSyntax != string::npos) && (posLocation != string::npos)) {
doBoth(posSyntax, posLocation);

// We continue because we do Syntax first, then Location
// And doLocation writes out all the lines it reads.
// Did we find Syntax?
if (posSyntax == string::npos) {
// Not found, write the line to output and continue reading.
// We should trim leading spaces though.
cout << a_line << endl;
continue;
}

// Try just the Syntax: line then? If we find a Location line
// in doSyntax, it gets correctly processed so we need a new line.
if (posSyntax != string::npos) {
doSyntax(posSyntax);
continue;
}

// Check for "Location:". We need a new line afterwards.
posLocation = a_line.find("Location:", 0, 9);
if (posLocation != string::npos) {
doLocation(posLocation);
continue;
}

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


void doSyntax(const size_t pos)
{
// Process the Syntax: part of the fixup.
// Read lines until we get a blank, (??) or a line
// with "Location:" in it. Keep everything then
// slice out each individual option for syntax.

string buffer;
size_t posLocation;

cout << tableSeparator << endl;
cout << "| Syntax | "; // 13 characters, no linefeed.

// Keep the rest of the Syntax: line.
buffer = a_line.substr(pos + 7, string::npos);

while (1) {
// 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)) {
break;
} else {
buffer += (" " + a_line);
}
}

// We have the full text of the syntax line in our buffer.
if (buffer.size() < 80-2-13) {
// Just write the whole line out.

cout << buffer;
cout << setw(80-13-buffer.size()) << "|" << endl;
} else {
// Need to split the buffer at any " or " text.

while (1) {
posLocation = buffer.find(" or ", 0, 4);
if (posLocation != string::npos) {
// We have a split.
string temp = buffer.substr(0, posLocation + 3);
cout << temp;
cout << setw(80-13-temp.size()) << "|" << endl;
buffer = buffer.substr(posLocation + 4, string::npos);

// Do we need another line?
if (buffer.find(" or ", 0, 4) != string::npos) {
cout << "| | ";
}
} else {
// No splitter. Write out the rest of the buffer.
cout << "| | " << buffer;
cout << setw(80-13-buffer.size()) << "|" << endl;
// We must have found Syntax:, read until we find Location: too.
buffer = "";
while (posLocation == string::npos) {
buffer += a_line += " ";
getline(cin, a_line);

// Should never happen ..... (FLW!)
if (cin.eof()) {
break;
}

posLocation = a_line.find("Location:", 0, 9);
}

// Add the last line to the buffer.
buffer += a_line;

// posSyntax is fine.
// PosLocation is relevant to the final line only.
// We need to find it in relation to buffer.
posLocation = buffer.find("Location:", posSyntax + 7, 9);

// Write out the syntax/location table.
// We assume the whole lot fits in 80 characters.
cout << tableSeparator << endl;
string temp = buffer.substr(posSyntax + 7, posLocation - posSyntax - 7);
cout << "| Syntax | " << temp;
cout << setw(80 - 13 - temp.size()) << "|" << endl;
cout << tableSeparator << endl;
temp = buffer.substr(posLocation + 9, string::npos);
cout << "| Location | " << temp;
cout << setw(80 - 13 - temp.size()) << "|" << endl;
cout << tableSeparator << endl << endl;



}

cout << tableSeparator << endl;

// Did we find a "Location:" line? If so, it's in a_line
// so process it because we "continue" on return from here
// and would lose the newly read line.
if (posLocation != string::npos) {
doLocation(posLocation);
}

}


void doLocation(const size_t pos)
{
// Process the Location: part of the fixup.
// There should be a tableSeparator just above from Syntax.

string buffer;

cout << "| Location | "; // 13 characters, no linefeed.

// Keep the rest of the Location: line.
buffer = a_line.substr(pos + 9, string::npos);

while (1) {
// Read a few more lines. We shouldn't hit EOF here! (FLW!)
getline(cin, a_line);
if (a_line.size() == 0) {
break;
} else {
buffer += (" " + a_line);
}
}

// We have the full text of the Location line in our buffer.
if (buffer.size() < 80-2-13) {
// Just write the whole line out.
cout << buffer;
cout << setw(80-13-buffer.size()) << "|" << endl;
} else {
// Need to split the buffer at WHAT EXACTLY???.
cout << buffer << " |" << endl;
}

cout << tableSeparator << endl;

// And write out the blank line we just read.
cout << a_line << endl;
}


void doBoth(const size_t posSyntax, const size_t posLocation)
{
// We have Syntax: and Location: on the same line.
// Split off the Location: part, keeping "Location:".
string locBuffer = a_line.substr(posLocation, string::npos);

// Keep just the Syntax: part.
a_line = a_line.substr(posSyntax + 7, posLocation - 8);

// Write out the syntax table cell and the syntax details.
cout << tableSeparator << endl;
cout << "| Syntax | " << a_line;
cout << setw(80-13-a_line.size()) << "|" << endl;
cout << tableSeparator << endl;

// Then do the Location details.
a_line = locBuffer;
doLocation(0);
}

0 comments on commit ee33c4e

Please sign in to comment.