add first few pages of PyBullet quickstart guide in Markdeep
This commit is contained in:
@@ -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>
|
||||
@@ -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.");
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
4680
docs/pybullet_quickstart_guide/WordpressPreview/MarkdeepUtility.js
Normal file
4680
docs/pybullet_quickstart_guide/WordpressPreview/MarkdeepUtility.js
Normal file
File diff suppressed because one or more lines are too long
4645
docs/pybullet_quickstart_guide/WordpressPreview/PrepareHTML.full.js
Normal file
4645
docs/pybullet_quickstart_guide/WordpressPreview/PrepareHTML.full.js
Normal file
File diff suppressed because it is too large
Load Diff
102
docs/pybullet_quickstart_guide/WordpressPreview/PrepareHTML.js
Normal file
102
docs/pybullet_quickstart_guide/WordpressPreview/PrepareHTML.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/** Converts <>&" to their HTML escape sequences */
|
||||
function escapeHTMLEntities(str) {
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
|
||||
/** 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 & last so that we don't recursively unescape
|
||||
// escaped escape sequences.
|
||||
return str.
|
||||
replace(/</g, '<').
|
||||
replace(/>/g, '>').
|
||||
replace(/"/g, '"').
|
||||
replace(/'/g, "'").
|
||||
replace(/–/g, '--').
|
||||
replace(/—/g, '---').
|
||||
replace(/&/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 <body> 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;
|
||||
4549
docs/pybullet_quickstart_guide/WordpressPreview/PreviewBlogPage.htm
Normal file
4549
docs/pybullet_quickstart_guide/WordpressPreview/PreviewBlogPage.htm
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
window.markdeepOptions={mode:"html"};
|
||||
@@ -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 <head> 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>
|
||||
6
docs/pybullet_quickstart_guide/WordpressPreview/markdeep.min.js
vendored
Normal file
6
docs/pybullet_quickstart_guide/WordpressPreview/markdeep.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user