Skip to content

Commit

Permalink
resolves #24 handle description list without text (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie authored Sep 20, 2023
1 parent 3a10c51 commit c8fba5c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global Opal */
class JupyterConverter {
constructor (backend) {
this.backend = backend
Expand Down Expand Up @@ -386,7 +387,7 @@ class JupyterConverter {
for (const term of terms) {
source += `* **${term.getText()}**\\`
}
if (dd) {
if (dd && dd !== Opal.nil) {
if (dd.hasText()) {
source += `
${dd.getText()}
Expand Down
19 changes: 19 additions & 0 deletions test/converter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,4 +388,23 @@ $$
`)
await debug(result, 'nested-blocks.ipynb')
})
it('should convert a description list without text', () => {
const inputFile = path.join(__dirname, 'fixtures', 'description-list-without-text.adoc')
const result = asciidoctor.convertFile(inputFile, {
safe: 'safe',
backend: 'jupyter',
to_file: false
})
expect(result).is.not.empty()
const ipynb = JSON.parse(result)
expect(ipynb.cells[0].source.join('')).is.equal(`# Basics
## Introduction
* **Basic Matrix Creation**\\`)
expect(ipynb.cells[1].source.join('')).is.equal(`import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(f"matrix={matrix}")
`)
})
})
11 changes: 11 additions & 0 deletions test/fixtures/description-list-without-text.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
= Basics

== Introduction

Basic Matrix Creation::
[%dynamic,python]
----
import numpy as np
matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(f"matrix={matrix}")
----

0 comments on commit c8fba5c

Please sign in to comment.