Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
decker
decker
Commits
6b054d58
Commit
6b054d58
authored
Jan 10, 2019
by
Jan-Philipp Stauffert
Browse files
Merge branch 'code-snippet' into 'master'
Include source code from local source files See merge request decker/decker!54
parents
72c44758
204292c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
package.yaml
View file @
6b054d58
...
...
@@ -68,6 +68,7 @@ dependencies:
-
pandoc-citeproc
-
pandoc-lens
-
pandoc-types
-
pandoc-include-code
-
process
-
pureMD5
-
random
...
...
src/Filter.hs
View file @
6b054d58
...
...
@@ -4,6 +4,7 @@ module Filter
,
OutputFormat
(
..
)
,
Disposition
(
..
)
,
processPandoc
,
Filter
.
includeCode
,
processSlides
,
useCachedImages
,
escapeToFilePath
...
...
@@ -55,6 +56,7 @@ import Text.Blaze.Html5 as H
import
qualified
Text.Blaze.Html5.Attributes
as
A
(
alt
,
class_
,
id
,
title
)
import
Text.Pandoc
import
Text.Pandoc.Definition
()
import
Text.Pandoc.Filter.IncludeCode
as
P
import
Text.Pandoc.Lens
import
Text.Pandoc.Shared
import
Text.Pandoc.Walk
...
...
@@ -216,6 +218,13 @@ zapImages :: Inline -> Inline
zapImages
Image
{}
=
Space
zapImages
inline
=
inline
-- start snippet includeCode
includeCode
::
Pandoc
->
Decker
Pandoc
includeCode
(
Pandoc
meta
blocks
)
=
do
included
<-
doIO
$
walkM
(
P
.
includeCode
Nothing
)
blocks
return
$
Pandoc
meta
included
-- end snippet includeCode
-- Transform inline image or video elements within the header line with
-- background attributes of the respective section.
handleBackground
::
Slide
->
Decker
Slide
...
...
src/Utilities.hs
View file @
6b054d58
...
...
@@ -288,6 +288,7 @@ readAndProcessMarkdown markdownFile disp = do
concatM
[
expandDeckerMacros
,
renderCodeBlocks
,
includeCode
,
provisionResources
,
processSlides
,
renderMediaTags
...
...
@@ -318,16 +319,16 @@ provisionResources pandoc = do
provisionMetaResource
::
FilePath
->
Provisioning
->
(
String
,
FilePath
)
->
Action
FilePath
provisionMetaResource
base
method
(
key
,
url
)
provisionMetaResource
base
method
kv
@
(
key
,
url
)
|
key
`
elem
`
runtimeMetaKeys
=
do
filePath
<-
urlToFilePathIfLocal
base
url
provisionResource
base
method
filePath
provisionMetaResource
base
method
(
key
,
url
)
provisionMetaResource
base
method
kv
@
(
key
,
url
)
|
key
`
elem
`
templateOverrideMetaKeys
=
do
cwd
<-
liftIO
$
Dir
.
getCurrentDirectory
filePath
<-
urlToFilePathIfLocal
cwd
url
provisionTemplateOverrideSupportTopLevel
cwd
method
filePath
provisionMetaResource
base
_
(
key
,
url
)
provisionMetaResource
base
_
kv
@
(
key
,
url
)
|
key
`
elem
`
compiletimeMetaKeys
=
do
filePath
<-
urlToFilePathIfLocal
base
url
need
[
filePath
]
...
...
@@ -639,6 +640,7 @@ elementAttributes =
,
"data-background-video"
,
"data-background-image"
,
"data-background-iframe"
,
"include"
]
-- | Resources in meta data that are needed at compile time. They have to be
...
...
stack.yaml
View file @
6b054d58
...
...
@@ -11,6 +11,7 @@ extra-deps:
-
libyaml-0.1.0.0
-
pandoc-2.4
-
pandoc-lens-0.6.3
-
pandoc-include-code-1.3.0.0
-
skylighting-0.7.4
-
skylighting-core-0.7.4
-
yaml-0.11.0.0
...
...
test/decks/include-code-deck.md
0 → 100644
View file @
6b054d58
---
title
:
Include Code
---
# Include the entire file
```
{.haskell include="/src/Filter.hs"}
```
# Include just a range
```
{.haskell include="/src/Filter.hs" startLine="221" endLine="224"}
```
# Include a tagged snippet
```
{.haskell include="/src/Filter.hs" snippet="includeCode"}
```
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment