Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #24 handle description list without text #27

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
----
Loading