Skip to content

Commit 291ed6e

Browse files
committed
Add template for MD tutorials & document; add mathjax to tutorial build
1 parent 705b37b commit 291ed6e

File tree

6 files changed

+192
-45
lines changed

6 files changed

+192
-45
lines changed

.github/workflows/builddocsite.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,18 @@ jobs:
8888
for fil in $dirname/*.md; do
8989
outfile="${dest}/$(basename "${fil%.md}.html")"
9090
echo "creating $outfile from $fil"
91-
pandoc --standalone ${fil} --css tutorial.css -o ${outfile}
91+
pandoc --standalone --mathjax --css tutorial.css -o ${outfile} ${fil}
9292
sed -i "s/<figure>/<BR clear=all><figure>/g" ${outfile}
9393
done
94-
git add ${dest}
94+
#git add ${dest}
9595
done
96-
cd ..
97-
96+
fil=template.md
97+
outfile=template.html
98+
echo "creating $outfile from $fil"
99+
pandoc --standalone --mathjax --css tutorial.css -o ${outfile} ${fil}
100+
sed -i "s/<figure>/<BR clear=all><figure>/g" ${outfile}
101+
#cd ..
102+
98103
- name: build tutorials index
99104
run: |
100105
cd scripts

MDhelp/README.md

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
1-
This directory contains a draft version of the GSAS-II help pages
2-
that have been converted from their MS-Word/HTML format into
3-
MarkDown. Web pages are generated with mkdocs
4-
5-
6-
Status of work 7/20/2025:
7-
8-
The 41 .md files have all been looked at, though some more carefully
9-
than others.
10-
11-
The next step is to tabulate Anchors used in the .md files
12-
(duplicates, missing names used in original .html)
13-
14-
Need python code that selects and opens new .html file based on anchor.
15-
16-
17-
Needs more work:
18-
19-
menu commands not described or well described in
20-
atoms, draw atoms & draw options. Should also describe the settings on
21-
draw options. Also, how does one expand a drawing to multiple cells? I
22-
always forget that trick!
23-
24-
Texture: are there places where capital greek letters should be used
25-
to differentiate symbols (\Phi vs \phi) orientation angles?
26-
27-
image.md: Make gain map appears to be moved to Image
28-
Controls/Calibrate/Multiimage gain map. Remove former? Units are not
29-
correct I think, for GSAS-II to Fit2D and pyFAI conversions
30-
31-
It would be nice to generate a PDF of all pages. Could not get
32-
https://mkdocs-to-pdf.readthedocs.io to work on MacOS, but perhaps on
33-
Linux? There are other choices:
34-
https://comwes.github.io/mkpdfs-mkdocs-plugin/index.html
35-
https://pypi.org/project/mkdocs-with-pdf/
36-
Everything seems to depend on https://weasyprint.org/
1+
This directory contains the files used to generate the GSAS-II help
2+
files, which are on the web at
3+
https://advancedphotonsource.github.io/GSAS-II-tutorials/help/ and are
4+
placed into the GSAS-II source code (at
5+
https://github.com/AdvancedPhotonSource/GSAS-II/tree/main/GSASII/help)
6+
7+
To view the pages as they are being edited use this command inside
8+
this directory::
9+
10+
mkdocs serve
11+
12+
and then open the address that is shown in a web browser. Web pages
13+
are rebuilt after any file is saved.
14+
15+
Note that this requires the following packages: mkdocs,
16+
mkdocs-material, python-markdown-math, mkdocs-static-i18n,
17+
mkdocs-to-pdf, & pymdown-extensions. All are available with
18+
pip. At least some with conda. Producing a .pdf also requires
19+
Google chrome or chromium.

MDtutorials/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1+
This directory contains files used to generate new GSAS-II tutorials. (The older tutorials were created using Microsoft Word to produce `.html` files directly.)
2+
The tutorials are placed on the web at
3+
https://advancedphotonsource.github.io/GSAS-II-tutorials/<subdir> using two commands:
4+
5+
pandoc --standalone --css tutorial.css --mathjax -o ${outfile} ${infil}
6+
sed -i "s/<figure>/<BR clear=all><figure>/g" ${outfile}
7+
8+
Note that on MacOS the sed command must be `sed -i "" "s/...`. The tutorial.css file is found in the MDtutorials directory and is copied to the same location as `$outfile`.
9+
110
# Steps in creating a new tutorial
211

312
> [!NOTE]
413
> Note: this is draft info and needs to be checked that I did not leave anything out
514
615
1. Create a new directory in the current location. Make sure not to use a name already in use for an existing tutorial (in the main directory, (https://github.com/AdvancedPhotonSource/GSAS-II-tutorials/tree/main).
716

8-
1. Create a &lt;filename&gt;.md file in the new directory. Name is arbitrary, but repeating the directory name is not a bad idea. Start the file with content like this:
17+
1. Create a &lt;filename&gt;.md file in the new directory. Name is arbitrary, but repeating the directory name is not a bad idea. Look at file `template.md` as an outline for formatting the tutorial. Start the file with content like this:
918

1019
---
1120
title: "Tutorial: ...anything you want to put here"
1221
---
1322
<!--- Don't change the HTML version of this file; edit the .md version -->
1423

1524
[//1]: <> (Comment: optional comment(s) here.)
16-
25+
26+
* Exercise files are found [here](data/index.html)
27+
1728
## Intro
1829

19-
look at the previously-created tutorials in this directory to see how formatting is done.
30+
omit the "Exercise files..." line if no exercise files are in use. Note that the `.../data/index.html` file is generated automatically.
2031

2132
1. Create a directory named `imgs` inside the new directory. Any images used in the tutorial go here.
2233

MDtutorials/TutorialGuide.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Build commands
9393

9494
The HTML file is constructed from the markdown file using commands:
9595

96-
pandoc --standalone ${infil} --css tutorial.css -o ${outfile}
96+
pandoc --standalone --css tutorial.css --mathjax -o ${outfile} ${infil}
9797
sed -i "s/<figure>/<BR clear=all><figure>/g" ${outfile}
9898

9999
Note that on MacOS the sed command must be sed -i "" "s/...". The tutorial.css file

MDtutorials/template.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: "Tutorial: Example tutorial to be written in Markdown"
3+
---
4+
5+
[//1]: <> (Comment: This comment is only in the .md file, as opposed to the next line which is raw HTML and creates that is placed into the .html file.)
6+
<!--- Don't change the HTML version of this file; edit the .md version -->
7+
8+
* Exercise files are found [here](data/index.html)
9+
10+
<a name=Intro></a>
11+
12+
## Intro
13+
14+
The ## indicates a top-level heading. Headings with a single # would be used for dividing a file into completely separate sections. Probably not what you would want. Start with an introduction and explain here what the tutorial is all about.
15+
16+
### Writing Equations
17+
18+
Note that subheadings use more than three # characters and sub-sub-headings can use four.
19+
20+
21+
Note that equations can generated with MathJax (TeX formatting). "In-line" equations, such as: Er${}_2$Ge${}_2$O${}_{7.5}$ or $Er_2Ge_2O_{7.5}$
22+
or $P 4_1 2_1 2$. Note that by default MathJax uses an *italic* font for letters and not numbers, but that can be overridden, like this $\textrm{Er}_2\textrm{Ge}_2\textrm{O}_{7.5}$ or
23+
$\rm Er_2Ge_2O_{7.5}$. Here is another in-line equation:
24+
$d(u,v) = 1 - \frac{ u \cdot v }{ \sqrt{ u^2 v^2 } }$. Note the difference to a display equation, as below. In-line equation delimiters are a single dollar sign ($).
25+
26+
#### Display Equations
27+
28+
Or, write display equations, such as
29+
$$ d(u,v) = 1 - \frac{ ( u - \bar{u} ) \cdot ( v - \bar{v} ) }{ \sqrt{ ( u - \bar{u} )^2 ( v - \bar{v} )^2}} $$
30+
which appear on a line by themselves, use with double-dollar sign delimiters ($$).
31+
32+
### Formatting text
33+
34+
A blank line indicates the start of a paragraph. Multiple blank lines are ignored. Lists can start with a "*" for a bullet or a number and a period (such as "0.") to indicate numbering. Use 4 spaces of indentation to indicated a nested list.
35+
36+
0. numbered list item 1
37+
0. numbered list item 2
38+
39+
* outer bullet list
40+
* inner bullet list
41+
42+
43+
44+
Format text between a single pair of asterisks for *italic* (like this `*italic*`) and doubled stars **bold** (like this `**bold**`).
45+
46+
47+
Text that should be displayed verbatim (without interpretation) can be
48+
placed between two
49+
"backtick" quotes (\`). So here `$A = a x^2 +b x + c$` is not interpreted as an equation.
50+
For a block of text that spans multiple lines, begin the block with three "back tick" quotes (\`\`\`) alone on the line and end the block with the same.
51+
52+
### Links
53+
54+
To provide a link to a location within the tutorial, define an anchor in HTML. Place this just before the location to be referenced. Here is the HTML code to define an anchor "myanchor":
55+
56+
```
57+
<a name=myanchor></a>
58+
```
59+
60+
To place a link to the anchor use a command to reference to that location, with a MarkDown command like this:
61+
```
62+
here is some text [with a link](#myanchor) provided
63+
```
64+
Likewise for an external reference, replace "#myanchor" with a URL (beginning with http:).
65+
66+
Here is some text [with a link](#Intro) provided to the Intro section and here is an external link: [GitHub ticket](https://github.com/AdvancedPhotonSource/GSAS-II/issues).
67+
68+
### Tables
69+
70+
Tables can be created using pipe characters (|) and dashes (-).
71+
Note that a colon can be used for right or left alignment or use two, as below for centering.
72+
73+
74+
```
75+
| `FontSize_incr` | Example |
76+
| :---: | ------------------------------------- |
77+
| 0 | [see file `font0.png`](imgs/font0.png) |
78+
| 3 | [see file `font0.png`](imgs/font3.png) |
79+
```
80+
81+
The code above creates the table below.
82+
83+
| `FontSize_incr` | Example |
84+
| :---: | ------------------------------------- |
85+
| 0 | [see file `font0.png`](imgs/font0.png) |
86+
| 3 | [see file `font0.png`](imgs/font3.png) |
87+
88+
See the markdown docs for other mechanisms to create tables.
89+
90+
91+
92+
### Figures
93+
94+
![Select the preference menu](imgs/menu1.png)
95+
96+
There are multiple ways to place figures into a tutorial. The simplest way is to use the standard MarkDown command:
97+
98+
```
99+
![Select the preference menu](imgs/menu1.png)
100+
```
101+
102+
Note the similarity of this with the command for creating links, except that an explanation mark (!) is placed at the beginning. The .css file used with tutorials places figures created with this command at the right margin.
103+
Typically one should place the figure before the text that references it. Leave a blank line after this command or the figure is placed into a paragraph -- probably not what you want, except perhaps with a very small figure.
104+
105+
Alternately one can use HTML commands to place an image at a particular place with an HTML command like this:
106+
107+
```
108+
<BR clear=all>
109+
<img src="./imgs/menu1.png" alt="extra peaks" width="200px;">
110+
```
111+
112+
113+
<BR clear=all>
114+
The `BR` command forces the image into a new area of the page and may not be wanted with a complex image layout.
115+
<img src="./imgs/menu1.png" alt="extra peaks" width=200px height=100px align="left" align="top" border=2px title="distorted image">
116+
The main advantage of the HTML command is that it allows one to rescale an image by specifying options such as `width` and/or `height`. Other options that may be of use are `align`, (align options are top, bottom, center, left, right), `title` (creates a tool-tip) and `border=2px` (for a 2 pixel black border around the image).
117+
Also, with an HTML command one can control how text is wrapped around an image.
118+
119+
The figure above was generated with this command embedded into the paragraph:
120+
```
121+
<img src="./imgs/menu1.png" alt="extra peaks" width=200px height=100px align="left" align="top" border=2px title="distorted image">
122+
```
123+
124+
<BR clear=all>
125+
126+
### Recommended
127+
128+
End the document with a table with the date and author(s). Here is the code to do that:
129+
130+
```
131+
----
132+
| |
133+
| ---: |
134+
| Brian Toby |
135+
| August 1, 2025 |
136+
```
137+
138+
----
139+
| |
140+
| ---: |
141+
| Brian Toby |
142+
| August 1, 2025 |

MDtutorials/tutorial.css

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@
4242
font-kerning: normal;
4343
}
4444
header {
45+
display: grid;
46+
background-image: url('https://advancedphotonsource.github.io/GSAS-II-tutorials/_images/gsas2.png');
47+
background-size: 60px;
48+
background-position: right; /* Centers the image within the header */
49+
background-repeat: no-repeat; /* Prevents the image from repeating */
50+
height: 60px;
4551
margin-top: 0em;
46-
margin-bottom: 1em;
52+
margin-bottom: 70px;
4753
text-align: center;
4854
counter-reset: h2cnt;
4955
}

0 commit comments

Comments
 (0)