Skip to content

Commit

Permalink
ref(stdlib): offload exporting to neorg, not the script
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed Apr 21, 2023
1 parent c65f152 commit 0bd9bff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
27 changes: 0 additions & 27 deletions stdlib.janet
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,3 @@
- An error if the given variable is not an abstract object."
(unless (neorg/abstract-object? abstract-object) (error "Variable is not an abstract object!"))
[(get abstract-object :bind) (get abstract-object :data)])

(defn neorg/export/code-block/markdown [abstract-object]
"Exports a code block as a markdown-formatted string.
Arguments:
- abstract-object: The abstract object representing the code block.
Returns:
- A string containing the markdown-formatted code block."
(def [bound-value, data] (neorg/abstract-object/unbind abstract-object))
(string "```" (or (data :language) "") "\n" (neorg/ts/node-text bound-value) "\n```"))

(defn neorg/export/code-block [abstract-object target]
"Exports a code block to the specified target language.
Arguments:
- abstract-object: The abstract object representing the code block.
- target: The target language to export the code block to.
Returns:
- The exported code block in the target language.
Throws:
- An error if the target language is not supported for code block export."
(try
(eval-string (string "(neorg/export/code-block/" target " " 'abstract-object ")"))
([_] (error (string "Language with name '" target "' not supported for code block export!")))))
5 changes: 3 additions & 2 deletions stdlib.norg
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ This defines the entry point for the Neorg standard library:
@code janet
(neorg/abstract-object
{:bind next
:data {:language language}
:export |(neorg/export/code-block $)})
:export |(neorg/export/code-block
:content (neorg/ts/node-text next)
:language language)})
@end

%Yup, this is the implementation of `comment`%
Expand Down

0 comments on commit 0bd9bff

Please sign in to comment.