-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
101 changed files
with
1,217 additions
and
1,866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
genieclust.inequality | ||
=================== | ||
===================== | ||
|
||
.. automodule:: genieclust.inequality | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright (C) 2020-2023, Marek Gagolewski <https://www.gagolewski.com> | ||
|
||
# I only want ```{r...``` and ```{python...``` to be recognised as | ||
# chunks to-be processed by knitr so that they can be placed within | ||
# MyST's nested admonitions | ||
|
||
all_patterns_new <- knitr:::all_patterns | ||
all_patterns_new$md$chunk.begin <- "^[\t >]*```\\s*\\{((r|python)( *[ ,].*)?)\\}\\s*$" | ||
all_patterns_new$md$chunk.end <- "^[\t >]*```\\s*$" | ||
unlockBinding("all_patterns", getNamespace("knitr")) | ||
assign("all_patterns", all_patterns_new, getNamespace("knitr")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2020-2023, Marek Gagolewski <https://www.gagolewski.com> | ||
|
||
set -e | ||
|
||
if [ ! -f "${1}" ]; then | ||
echo "The input file does not exist or was not provided." | ||
exit 1 | ||
fi | ||
|
||
basename="${1/%.Rmd/}" | ||
tmpdir="${1/%.Rmd/}" | ||
knitrfile="tmp-md-${1}" | ||
outfile="${1/%.Rmd/.md}" | ||
|
||
echo "Rmd2md ${1} → ${outfile}..." | ||
|
||
rm -f "${knitrfile}" | ||
rm -f "${outfile}" | ||
|
||
#mkdir -p "cache" | ||
|
||
touch "${knitrfile}" | ||
|
||
echo "\`\`\`{r __rinit__,echo=FALSE,warning=FALSE,message=FALSE,results='hide'}" >> "${knitrfile}" | ||
cat options.R >> "${knitrfile}" | ||
echo "\`\`\`" >> "${knitrfile}" | ||
echo "" >> "${knitrfile}" | ||
|
||
echo "\`\`\`{python __pyinit__,echo=FALSE,warning=FALSE,message=FALSE,results='hide'}" >> "${knitrfile}" | ||
cat options.py >> "${knitrfile}" | ||
echo "\`\`\`" >> "${knitrfile}" | ||
echo "" >> "${knitrfile}" | ||
|
||
cat "${1}" >> "${knitrfile}" | ||
|
||
# remove HTML comments <!-- ... --> (in a brute force way; beware) | ||
perl -0pi -e 's/(?s)<!--.*?-->\n?//g' "${knitrfile}" | ||
|
||
Rscript -e "\ | ||
library('knitr'); \ | ||
source('Rmd2md-patch.R'); \ | ||
opts_knit\$set( | ||
progress=FALSE, \ | ||
verbose=TRUE, \ | ||
unnamed.chunk.label='${basename}' \ | ||
); \ | ||
opts_chunk\$set( \ | ||
cache.path='${tmpdir}-cache/', \ | ||
fig.path='${tmpdir}-figures/' \ | ||
); \ | ||
knit('${knitrfile}', '${outfile}') | ||
" | ||
|
||
rm -f "${knitrfile}" | ||
|
||
|
||
if [ -d "${tmpdir}-figures" ] | ||
then | ||
for f in ${tmpdir}-figures/*.pdf | ||
do | ||
if [ "$f" -nt "${f/.pdf/.png}" ] | ||
then | ||
echo "Converting ${f} to png...." | ||
convert -density 96 "$f" "${f/.pdf/.png}" | ||
fi | ||
done | ||
fi | ||
|
||
# move #> comments inside code blocks outside | ||
Rscript -e "\ | ||
source('extract-code-comments.R'); \ | ||
extract_code_comments('${outfile}') | ||
" | ||
|
||
# convert paths: sphinx/chapter/ → ./ | ||
sed -ri -e's/sphinx\/chapter\///g' "${outfile}" | ||
|
||
# {chapref}`ref` → {numref}`Chapter %s <ref>` | ||
sed -ri -e's/\{numref\}`chap:([^`]+)`/{numref}`Chapter %s <chap:\1>`/g' "${outfile}" | ||
|
||
# {help}`topic` → {command}`help`{code}`("topic")` | ||
sed -ri -e's/\{help\}`([^`]+)`/{command}`help`{code}`("\1")`/g' "${outfile}" | ||
|
||
# horizontal lines are bigskips | ||
sed -i -e 's/^\-\-\-$/```{raw} latex\n\\bigskip\n```\n\n```{raw} html\n<div style="margin-top: 1em"><\/div>\n```\n/g' "${outfile}" | ||
|
||
# merge input and output chunks: | ||
sed -rz --in-place 's/(\s)```\n\n+```\n/\1/g' "${outfile}" | ||
# merge output and input chunks: | ||
sed -rz --in-place 's/(\s)```\n\n+```r\n/\1/g' "${outfile}" | ||
sed -rz --in-place 's/(\s)```\n\n+```python\n/\1/g' "${outfile}" | ||
|
||
echo "Rmd2md ${1} → ${outfile} DONE." |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.