add first few pages of PyBullet quickstart guide in Markdeep

This commit is contained in:
Erwin Coumans
2017-12-06 13:58:56 -08:00
parent 5906923324
commit 277b6bb8a1
26 changed files with 14875 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<meta charset="utf-8" lang="en">
Hello Markdeep!
- Hello
- lists!
Hello MathJax:
\[f(0)=\frac{1}{2\cdot\pi\cdot i}\cdot \oint_{|z|=1} \frac{f(z)}{z} \textrm{d}z\]
<script src="MarkdeepUtility.js"></script>

View File

@@ -0,0 +1,43 @@
import re
if(__name__=="__main__"):
# Assemble the script which embeds the Markdeep page into the preview blog
PreviewBlogPage=open("PreviewBlogPage.htm","rb").read().decode("utf-8");
HeadMatch=re.search("<head(.*?)>(.*?)</head>",PreviewBlogPage,re.DOTALL);
HeadAttributes=HeadMatch.group(1);
FullDocumentHead=HeadMatch.group(2);
BodyMatch=re.search("<body(.*?)>(.*?)</body>",PreviewBlogPage,re.DOTALL);
BodyAttributes=BodyMatch.group(1);
FullPreviewBody=BodyMatch.group(2);
ArticleHTMLCodeMacro="$(ARTICLE_HTML_CODE)";
iArticleHTMLCodeMacro=FullPreviewBody.find(ArticleHTMLCodeMacro);
DocumentBodyPrefix=FullPreviewBody[0:iArticleHTMLCodeMacro];
DocumentBodySuffix=FullPreviewBody[iArticleHTMLCodeMacro+len(ArticleHTMLCodeMacro):];
FullPrepareHTMLCode=open("PrepareHTML.js","rb").read().decode("utf-8");
ReplacementList=[
("$(FULL_DOCUMENT_HEAD)",FullDocumentHead),
("$(DOCUMENT_BODY_PREFIX)",DocumentBodyPrefix),
("$(DOCUMENT_BODY_SUFFIX)",DocumentBodySuffix)
];
for Macro,Replacement in ReplacementList:
FullPrepareHTMLCode=FullPrepareHTMLCode.replace(Macro,Replacement.replace("\r\n","\\r\\n\\\r\n").replace("'","\\'"));
# Generate code which sets body and head attributes appropriately
for Element,AttributeCode in [("head",HeadAttributes),("body",BodyAttributes)]:
FullPrepareHTMLCode+="\r\n// Setting "+Element+" attributes\r\n";
for Match in re.finditer("(\\w+)=\\\"(.*?)\\\"",AttributeCode):
FullPrepareHTMLCode+="document."+Element+".setAttribute(\""+Match.group(1)+"\",\""+Match.group(2)+"\");\r\n";
open("PrepareHTML.full.js","wb").write(FullPrepareHTMLCode.encode("utf-8"));
# Concatenate all the scripts together
SourceFileList=[
"PrepareHTML.full.js",
"SetMarkdeepMode.js",
"markdeep.min.js",
"DisplayMarkdeepOutput.js",
"InvokeMathJax.js"
];
OutputCode="\r\n\r\n".join(["// "+SourceFile+"\r\n\r\n"+open(SourceFile,"rb").read().decode("utf-8") for SourceFile in SourceFileList]);
OutputFile=open("MarkdeepUtility.js","wb");
OutputFile.write(OutputCode.encode("utf-8"));
OutputFile.close();
print("Done.");

View File

@@ -0,0 +1,6 @@
BodyHTML=document.body.innerHTML;
BeginTag="<!-- MARKDEEP_BEGIN -->";
EndTag="<!-- MARKDEEP_END -->";
BodyHTML=BodyHTML.slice(BodyHTML.indexOf(BeginTag)+BeginTag.length,BodyHTML.lastIndexOf(EndTag));
document.getElementById("BodyDisplayBox").textContent=BodyHTML;
document.head.innerHTML=FullDocumentHead;

View File

@@ -0,0 +1,4 @@
var MathjaxScript=document.createElement("script");
MathjaxScript.type="text/javascript";
MathjaxScript.src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.head.appendChild(MathjaxScript);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
/** Converts <>&" to their HTML escape sequences */
function escapeHTMLEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
/** Restores the original source string's '<' and '>' as entered in
the document, before the browser processed it as HTML. There is no
way in an HTML document to distinguish an entity that was entered
as an entity.*/
function unescapeHTMLEntities(str) {
// Process &amp; last so that we don't recursively unescape
// escaped escape sequences.
return str.
replace(/&lt;/g, '<').
replace(/&gt;/g, '>').
replace(/&quot;/g, '"').
replace(/&#39;/g, "'").
replace(/&ndash;/g, '--').
replace(/&mdash;/g, '---').
replace(/&amp;/g, '&');
}
/**
\param node A node from an HTML DOM
\return A String that is a very good reconstruction of what the
original source looked like before the browser tried to correct
it to legal HTML.
*/
function nodeToMarkdeepSource(node, leaveEscapes) {
var source = node.innerHTML;
// Markdown uses <john@bar.com> e-mail syntax, which HTML parsing
// will try to close by inserting the matching close tags at the end of the
// document. Remove anything that looks like that and comes *after*
// the first fallback style.
source = source.replace(/(?:<style class="fallback">[\s\S]*?<\/style>[\s\S]*)<\/\S+@\S+\.\S+?>/gim, '');
// Remove artificially inserted close tags
source = source.replace(/<\/h?ttps?:.*>/gi, '');
// Now try to fix the URLs themselves, which will be
// transformed like this: <http: casual-effects.com="" markdeep="">
source = source.replace(/<(https?): (.*?)>/gi, function (match, protocol, list) {
// Remove any quotes--they wouldn't have been legal in the URL anyway
var s = '<' + protocol + '://' + list.replace(/=""\s/g, '/');
if (s.substring(s.length - 3) === '=""') {
s = s.substring(0, s.length - 3);
}
// Remove any lingering quotes (since they
// wouldn't have been legal in the URL)
s = s.replace(/"/g, '');
return s + '>';
});
// Remove the "fallback" style tags
source = source.replace(/<style class=["']fallback["']>.*?<\/style>/gmi, '');
source = unescapeHTMLEntities(source);
return source;
}
// $ (FULL_DOCUMENT_HEAD) is replaced by the contents of the <head> found in
// PreviewBlogPage.htm. This document head will overwrite whatever Markdeep does to
// the head at the very end.
FullDocumentHead='\
$(FULL_DOCUMENT_HEAD)\
';
// This code is placed at the beginning of the body before the Markdeep code.
// $ (DOCUMENT_BODY_PREFIX) is everything in the body of PreviewBlogPage.htm up to
// $ (ARTICLE_HTML_CODE).
DocumentBodyPrefix='\
$(DOCUMENT_BODY_PREFIX)\
<!-- MARKDEEP_BEGIN -->\
<pre class="markdeep">\
';
// This code is placed at the end of the body after the Markdeep code.
// $ (DOCUMENT_BODY_SUFFIX) is everything in the body of PreviewBlogPage.htm after
// $ (ARTICLE_HTML_CODE).
DocumentBodySuffix='\
</pre>\
<!-- MARKDEEP_END -->\
<div>Document &lt;body&gt; code:<br/>\
<textarea cols="40" rows="10" id="BodyDisplayBox"></textarea></div>\
$(DOCUMENT_BODY_SUFFIX)\
';
// Get the full Markdeep code from the .md.html file without the script invocation
MarkdeepCode=nodeToMarkdeepSource(document.body);
MarkdeepCode=MarkdeepCode.slice(0,MarkdeepCode.lastIndexOf("<script"));
// Bring it into a form where it can be pasted into an HTML document
SanitizedMarkdeepCode=escapeHTMLEntities(MarkdeepCode);
// Surround it by the prefix and suffix code and set that as body code
document.body.innerHTML=DocumentBodyPrefix+SanitizedMarkdeepCode+DocumentBodySuffix;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
window.markdeepOptions={mode:"html"};

View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<body>
<script>window.markdeepOptions={mode:"script"};</script>
<script src="./markdeep.min.js"></script>
<div>Document &lt;head&gt; additions:<br/>
<textarea cols="80" rows="40" id="HeadDisplayBox"></textarea></div>
<script>
// Get the complete Markdeep and hljs stylesheet
FullStylesheet=window.markdeep.stylesheet();
// It should consist of three <style> tags which we pick apart
StyleTagList=FullStylesheet.split("<style>");
// The second one defines section number, which we do not want, so we
// just drop it. The other two are Markdeep and hljs styles.
MarkdeepStylesheet="<style>"+StyleTagList[1];
HLJSStylesheet="<style>"+StyleTagList[3];
// Now lets show the user what we found
document.getElementById("HeadDisplayBox").textContent=
"<!-- Markdeep styles -->\r\n"
+MarkdeepStylesheet
+"\r\n\r\n<!-- hljs styles -->\r\n"
+HLJSStylesheet
+"\r\n\r\n<!-- MathJax invocation -->\r\n<script type=\"text/javascript\" async=\"\" src=\"https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML\">\r\n";
</script>
</body>
</html>

File diff suppressed because one or more lines are too long