Skip to content

Commit

Permalink
Some small improvements
Browse files Browse the repository at this point in the history
- Less input files.
- Inline code with highlight.
- Documentation.
  • Loading branch information
Nützi, Gabriel committed Jan 4, 2022
1 parent 7a33492 commit 9d3c9b5
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ Test*
!Content.html
Content.jira

.venv
.envrc
node_modules
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"PandocCiter.DefaultBib": "literature/bibliography.bib",
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.tabSize": 4,
Expand Down Expand Up @@ -36,8 +37,8 @@
"name": "latexmk"
}
],
"PandocCiter.DefaultBib": "literature/bibliography.bib",
"prettier.configPath": "tools/.prettierrc",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv",
"python.formatting.provider": "yapf",
"python.formatting.yapfArgs": [
"--style",
Expand All @@ -48,6 +49,7 @@
"python.linting.pycodestyleEnabled": false,
"python.linting.pylamaEnabled": true,
"python.linting.pylintEnabled": false,
"python.terminal.activateEnvironment": true,
"search.exclude": {
"**/node_modules": true
},
Expand Down
2 changes: 1 addition & 1 deletion Content.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ <h3 data-number="2.3.2" id="sec:multi-line-table"><span class="header-section-nu
<h1 class="unnumbered" id="references">References</h1>
<div id="refs" class="references csl-bib-body" role="doc-bibliography">
<div id="ref-nuetzig_thesis_2016" class="csl-entry" role="doc-biblioentry">
<div class="csl-left-margin">[1] </div><div class="csl-right-inline">G. Nützi, <span>‘Non-smooth granular rigid body dynamics with applications to chute flows’</span>, PhD thesis, ETH Zurich; ETH Zürich, Zürich, 2016. </div>
<div class="csl-left-margin">[1] </div><div class="csl-right-inline">G. Nützi, <span><a href="https://doi.org/10.3929/ethz-a-010662262">Non-smooth granular rigid body dynamics with applications to chute flows</a></span>, PhD thesis, ETH Zurich; ETH Zürich, Zürich, 2016. </div>
</div>
<div id="ref-rockafellar_convex_2015" class="csl-entry" role="doc-biblioentry">
<div class="csl-left-margin">[2] </div><div class="csl-right-inline">R. T. Rockafellar, <em>Convex analysis</em>. Princeton: Princeton University Press, 2015 [Online]. Available: <a href="https://www.degruyter.com/view/title/516543">https://www.degruyter.com/view/title/516543</a></div>
Expand Down
Binary file removed Content.pdf
Binary file not shown.
23 changes: 9 additions & 14 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,20 @@ choco install pandoc

### Python

Install a recent `python3` (>= 3.6) and the following packages:
Install a recent `python3` (>= 3.9) and the following packages.

Setup a python environment in `.venv` with
`python -m venv --system-site-packages ./.venv` and install the packages:

```shell
python -m venv --system-site-packages .venv # or simply symlink to an existing one.
source .venv/bin/activate
pip3 install -r tools/.requirements
```

The best way is to setup a python environment `python venv` since `pandoc`. The VS Code config `python.pythonPath` path needs to be set.

The VS Code tasks get the `${config:python.pythonPath}`
directly as an argument and modify the environement and `pandoc` will use the right python when launching the filters.

You can also start VS Code like this to have the proper `python` enabled:

```bash
# Activate your python env.
source ~/.env/myPython3.8Env/activate
# Start code
cd TechnicalMarkdown && code -n .
```
The VS Code tasks pass the config `${config:python.pythonEnv}`
directly as an argument to `gradlew` (if not set `python` is the default). The tasks are run in a shell where `./.venv/bin/activate` has been called.
Then, `pandoc` will use the correct python when launching the filters.

You can also use the ignored [.envrc](.envrc) file with [direnv](https://github.com/direnv/direnv).

Expand Down
29 changes: 17 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ val defineEnvironment by tasks.register<Task>("defineEnvironment") {
outputs.upToDateWhen({true})

doLast({

pythonPaths.forEach {
if(!it.exists()) {
throw RuntimeException(
Expand All @@ -117,10 +117,10 @@ val defineEnvironment by tasks.register<Task>("defineEnvironment") {
checkCmd(arrayOf(pythonExe, "--version"), null)
checkPandocInstall(pandocExe)

logger.quiet("Pandoc Exe: $pandocExe")
logger.quiet("Python Exe: $pythonExe")
logger.quiet("Python Path: ${pythonPaths.contentToString()}")
logger.quiet("Lua Path: ${luaPaths.contentToString()}")
logger.info("Pandoc Exe: $pandocExe")
logger.info("Python Exe: $pythonExe")
logger.info("Python Path: ${pythonPaths.contentToString()}")
logger.info("Lua Path: ${luaPaths.contentToString()}")

})
}
Expand All @@ -131,20 +131,21 @@ val compileLess by tasks.register<Exec>("compileLess") {
description = "Compile Less"
dependsOn(initBuild, defineEnvironment)

val lessFile = fileTree("${project.rootDir}/convert/css/src/"){ include("main.less") }.getFiles().elementAt(0)
val lessMainFile = fileTree("${project.rootDir}/convert/css/src/"){ include("main.less") }.getFiles().elementAt(0)
val lessFiles = fileTree("${project.rootDir}/convert/css/src/"){ include("*.less") }.getFiles()
val cssFile = file("${project.rootDir}/convert/css/main.css")

inputs.files(lessFile)
inputs.files(lessMainFile, lessFiles)
outputs.file(cssFile)

val lessCompiler = file("$binDir/lessc")

doFirst({
println("Executing Less Compilation: '$lessFile' -> '$cssFile'")
println("Executing Less Compilation: '$lessMainFile' -> '$cssFile'")
})

executable(lessCompiler)
args("--include-path=convert/css/src", lessFile, cssFile)
args("--include-path=convert/css/src", lessMainFile, cssFile)

workingDir(project.rootDir)
}
Expand All @@ -161,8 +162,9 @@ data class PandocSettings(

fun createPandocSettings(): PandocSettings {
var env = globalEnv.toMutableMap()
env.addExecutableDirToPath(pandocExe)
env.addExecutableDirToPath(pythonExe)
logger.quiet("First PATH: '${env["PATH"]}")
//env.addExecutableDirToPath(pythonExe)
//env.addExecutableDirToPath(pandocExe)
env["ROOT_DIR"] = "${project.rootDir}"
env["PYTHON_PATH"] = env.getOrDefault("PYTHON_PATH", "") + pathSep + pythonPaths.joinToString(separator = pathSep)
env["LUA_PATH"] = env.getOrDefault("LUA_PATH", "") + pathSep + luaPaths.flatMap({v -> listOf("$v/?", "$v/?.lua") }).joinToString(separator=";")
Expand Down Expand Up @@ -193,6 +195,8 @@ abstract class PandocTask @Inject constructor() : Exec() {
@get:InputDirectory
abstract val assetFiles: Property<FileTree>
@get:InputDirectory
abstract val literatureFiles: Property<FileTree>
@get:InputDirectory
abstract val convertFiles: Property<FileTree>

@get:OutputFile
Expand All @@ -218,12 +222,13 @@ abstract class PandocTask @Inject constructor() : Exec() {
additionalArgs.convention(arrayOf())
markdownFiles.convention(project.fileTree("${project.rootDir}/chapters/"){include("**/*.md", "**/*.html")})
assetFiles.convention(project.fileTree("${project.rootDir}/files/"){ include("**/*") })
literatureFiles.convention(project.fileTree("${project.rootDir}/literature/"){ include("**/*") })
convertFiles.convention(project.fileTree("${project.rootDir}/convert/"){
include("pandoc/**/*")
include("scripts/**/*")
})

inputs.files(inputFile, markdownFiles, assetFiles, convertFiles)
inputs.files(inputFile, markdownFiles, assetFiles, convertFiles, literatureFiles)
outputs.file(outputFile)

executable(settings.pandocExe)
Expand Down
22 changes: 20 additions & 2 deletions convert/css/main.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions convert/css/src/code.less
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
@import "defines.less";

.define-code() {

code{
code {
font-family: Fira Code;
font-size: 11pt;
padding-left: 3pt;
padding-right: 3pt;
border-radius: 3pt;
background-color: @main-float-background-color;
}

div.sourceCode {
Expand All @@ -14,7 +17,13 @@
border-color: @main-float-border-color;
border-width: 1.5pt;
margin: 0.5ex;
border-radius: 4pt;
border-radius: 5pt;

code {
padding-left: 0pt;
padding-right: 0pt;
background-color: transparent
}
}

pre.numberSource {
Expand Down

0 comments on commit 9d3c9b5

Please sign in to comment.