Skip to content

Commit c010d35

Browse files
Improved help and version bump
1 parent cfef8e1 commit c010d35

12 files changed

Lines changed: 323 additions & 151 deletions

File tree

README.md

Lines changed: 187 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -59,88 +59,193 @@ $ liaex
5959
No input defined
6060
LiaScript-Exporter
6161

62-
-h --help show this help
63-
-i --input file to be used as input
64-
-p --path path to be packed, if not set, the path of the input file is used
65-
-o --output output file name (default is output), the ending is define by the format
66-
-f --format scorm1.2, scorm2004, json, fullJson, web, ims, pdf (default is json)
67-
-v --version output the current version
68-
69-
-k --key responsive voice key
70-
71-
SCORM settings:
72-
73-
--scorm-organization set the organization title
74-
--scorm-masteryScore set the scorm masteryScore (a value between 0 -- 100), default is 0
75-
--scorm-typicalDuration set the scorm duration, default is PT0H5M0S
76-
--scorm-iframe use an iframe, when a SCORM starting parameter is not working
77-
--scorm-embed embed the Markdown into the JS code, use in Moodle 4 to handle restrictions with dynamic loading
78-
79-
IMS settings:
80-
81-
--ims-indexeddb Use IndexedDB to store data persistently
82-
83-
WEB settings:
84-
85-
--web-iframe Use an iframed version to hide the course URL.
86-
--web-indexeddb This will allow to store data within the browser using indexeddb, you can optionally pass a unique key (by default one is generated randomly).
87-
--web-zip By default the result is not zipped, you can change this with this parameter.
88-
89-
Android settings:
90-
91-
--android-sdk Specify sdk.dir which is required for building.
92-
--android-appName Name of the App (Main-title is used as default).
93-
--android-appId Required to identify your App reverse url such as io.github.liascript
94-
--android-icon Optional icon with 1024x1024 px
95-
--android-splash Optional splash image with 2732x2732 px
96-
--android-splashDuration Duration for splash-screen default 0 milliseconds
97-
--android-preview Open course in Android-Studio
98-
99-
PDF settings:
100-
101-
--pdf-stylesheet Inject an local CSS for changing the appearance.
102-
--pdf-theme LiaScript themes: default, turquoise, blue, red, yellow
103-
--pdf-timeout Set an additional time horizon to wait until finished.
104-
105-
https://github.com/puppeteer/puppeteer/blob/main/docs/api/puppeteer.pdfoptions.md
106-
107-
--pdf-preview Open preview-browser (default false), print not possible
108-
--pdf-scale Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.
109-
--pdf-displayHeaderFooter Display header and footer. Defaults to false.
110-
--pdf-headerTemplate HTML template for the print header, inject classes date, title, url, pageNumber, totalPages
111-
--pdf-footerTemplate HTML template for the print footer. Should use the same format as the headerTemplate
112-
--pdf-printBackground Print background graphics. Defaults to false
113-
--pdf-landscape Paper orientation. Defaults to false.
114-
--pdf-pageRanges Paper ranges to print, e.g., "1-5, 8, 11-13"
115-
--pdf-format Paper format. If set, takes priority over width or height options. Defaults to a4.
116-
--pdf-width Paper width, accepts values labeled with units.
117-
--pdf-height Paper height, accepts values labeled with units.
118-
--pdf-margin-top Top margin, accepts values labeled with units.
119-
--pdf-margin-right Right margin, accepts values labeled with units.
120-
--pdf-margin-bottom Bottom margin, accepts values labeled with units.
121-
--pdf-margin-left Left margin, accepts values labeled with units.
122-
--pdf-preferCSSPageSize Give any CSS @page size declared in the page priority over what is declared in width and height or format options.
123-
--pdf-omitBackground Hides default white background and allows capturing screenshots with transparency. Defaults to true.
124-
125-
Project settings:
126-
127-
--project-no-meta Disable the generation of meta information for OpenGraph and Twitter-cards.
128-
--project-no-categories Disable the filter for categories/tags.
129-
--project-category-blur Enable this and the categories will be blurred instead of deleted.
130-
--project-generate-pdf PDFs are automatically generated and added to every card.
131-
--project-generate-scrom12 SCORM12 and pass additional scrom settings.
132-
--project-generate-scrom2004 SCORM2004 and pass additional scrom settings.
133-
--project-generate-ims IMS resources with additional config settings.
134-
--project-generate-cache Only generate new files, if they do not exist.
135-
136-
RDF settings:
137-
138-
--rdf-format Output format n-quads, json-ld (defaults to json-ld).
139-
--rdf-preview Output the result to the console.
140-
--rdf-url Refer to an external URL when parsing a local project.
141-
--rdf-type Course frm schmema.org is applied as default, overwrite this with EducationalResource, etc.
142-
--rdf-license Add a license-URL, otherwise if url was provided as input, this will check for an existing LICENSE file.
143-
--rdf-educationalLevel Typically beginner, intermediate or advanced, and formal sets of level indicators.
62+
Export your LiaScript Markdown files to different formats. The following
63+
commandline options are available. Based on the selected output format,
64+
additional options can be used.
65+
66+
-h --help show this help
67+
-i --input file to be used as input
68+
-p --path path to be packed, if not set, the path of the input
69+
file is used
70+
-o --output output file name (default is output), the ending is
71+
define by the format
72+
-s --style additional styling to passed to the export, can be
73+
used for fixes, such as "height: 100vh; width: 100%;
74+
border: 2px;"
75+
-f --format scorm1.2, scorm2004, json, fullJson, web, ims, pdf,
76+
android, linkedData (default is json)
77+
-v --version output the current version
78+
-k --key responsive voice key
79+
80+
SCORM settings:
81+
82+
SCORM (Sharable Content Object Reference Model) 1.2 & 2004 are standards for
83+
e-learning content that can be imported into LMS platforms like Moodle,
84+
Blackboard, and others.
85+
86+
Learn more: https://scorm.com/scorm-explained/
87+
88+
Known SCORM configurations per LMS:
89+
https://www.npmjs.com/package/@liascript/exporter#scorm-examples
90+
91+
--scorm-organization set the organization title
92+
--scorm-masteryScore set the scorm masteryScore (a value between 0
93+
-- 100), default is 0
94+
--scorm-typicalDuration set the scorm duration, default is PT0H5M0S
95+
--scorm-iframe use an iframe, when a SCORM starting
96+
parameter is not working
97+
--scorm-embed embed the Markdown into the JS code,
98+
use in Moodle 4 to handle restrictions with dynamic
99+
loading
100+
101+
IMS settings:
102+
103+
IMS (Instructional Management Systems) Content Package is an interoperable
104+
standard format for packaging learning content between different LMSes.
105+
106+
Learn more: https://www.imsglobal.org/content/packaging/index.html
107+
108+
--ims-indexeddb Use IndexedDB to store data persistently
109+
110+
WEB settings:
111+
112+
Pack the project into a self contained web project that can be hosted
113+
everywhere.
114+
115+
--web-iframe Use an iframed version to hide the
116+
course URL.
117+
--web-indexeddb This will allow to store data within the
118+
browser using indexeddb, you can optionally pass a
119+
unique key (by default one is generated randomly).
120+
--web-zip By default the result is not
121+
zipped, you can change this with this parameter.
122+
123+
Android settings:
124+
125+
Android export generates a native Android application (.apk) from your LiaScript
126+
course using Capacitor. This requires the Android SDK to be installed on your
127+
system.
128+
129+
Learn more:
130+
- Capacitor: https://capacitorjs.com/
131+
- Android SDK: https://developer.android.com/studio
132+
133+
--android-sdk Specify sdk.dir which is required for
134+
building.
135+
--android-appName Name of the App (Main-title is used as
136+
default).
137+
--android-appId Required to identify your App reverse url
138+
such as io.github.liascript
139+
--android-icon Optional icon with 1024x1024 px
140+
--android-splash Optional splash image with 2732x2732 px
141+
--android-splashDuration Duration for splash-screen default 0 milliseconds
142+
--android-preview Open course in Android-Studio
143+
144+
PDF settings:
145+
146+
PDF export generates printable documents from your LiaScript course using
147+
Puppeteer, a headless Chrome browser automation tool. This allows for
148+
high-quality rendering of all course elements including interactive content.
149+
150+
Learn more: https://pptr.dev/
151+
152+
--pdf-stylesheet Inject an local CSS for changing the
153+
appearance.
154+
--pdf-theme LiaScript themes: default, turquoise,
155+
blue, red, yellow
156+
--pdf-timeout Set an additional time horizon to wait
157+
until finished.
158+
--pdf-preview Open preview-browser (default false),
159+
print not possible
160+
161+
The following are puppeteer specific settings.
162+
163+
Learn more:
164+
https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagepdfoptions
165+
166+
--pdf-scale Scale of the webpage rendering.
167+
Defaults to 1. Scale amount must be between 0.1 and
168+
2.
169+
--pdf-displayHeaderFooter Display header and footer. Defaults to false.
170+
--pdf-headerTemplate HTML template for the print header, inject
171+
classes date, title, url, pageNumber, totalPages
172+
--pdf-footerTemplate HTML template for the print footer. Should use
173+
the same format as the headerTemplate
174+
--pdf-printBackground Print background graphics. Defaults to false
175+
--pdf-landscape Paper orientation. Defaults to false.
176+
--pdf-pageRanges Paper ranges to print, e.g., "1-5, 8,
177+
11-13"
178+
--pdf-format Paper format. If set, takes priority
179+
over width or height options. Defaults to a4.
180+
--pdf-width Paper width, accepts values labeled
181+
with units.
182+
--pdf-height Paper height, accepts values labeled
183+
with units.
184+
--pdf-margin-top Top margin, accepts values labeled with
185+
units.
186+
--pdf-margin-right Right margin, accepts values labeled with
187+
units.
188+
--pdf-margin-bottom Bottom margin, accepts values labeled with
189+
units.
190+
--pdf-margin-left Left margin, accepts values labeled with
191+
units.
192+
--pdf-preferCSSPageSize Give any CSS @page size declared in the page
193+
priority over what is declared in width and height
194+
or format options.
195+
--pdf-omitBackground Hides default white background and allows
196+
capturing screenshots with transparency. Defaults to
197+
true.
198+
199+
Project settings:
200+
201+
A project is a bundle for multiple LiaScript resource into a single project
202+
overview page, based on a provided yaml description.
203+
204+
Learn more: https://www.npmjs.com/package/@liascript/exporter#project
205+
206+
Example:
207+
- Input: https://github.com/LiaBooks/liabooks.github.com/blob/main/project.yaml
208+
- Output: https://liabooks.github.io
209+
210+
--project-no-meta Disable the generation of meta information
211+
for OpenGraph and Twitter-cards.
212+
--project-no-rdf Disable the generation of json-ld.
213+
--project-no-categories Disable the filter for categories/tags.
214+
--project-category-blur Enable this and the categories will be blurred
215+
instead of deleted.
216+
--project-generate-scrom12 SCORM12 and pass additional scrom settings.
217+
--project-generate-scrom2004SCORM2004 and pass additional scrom settings.
218+
--project-generate-ims IMS resources with additional config settings.
219+
--project-generate-pdf PDFs are automatically generated and added to
220+
every card.
221+
--project-generate-cache Only generate new files, if they do not exist.
222+
223+
RDF settings:
224+
225+
RDF (Resource Description Framework) export generates structured metadata for
226+
your LiaScript course or your project-yaml in standard linked data formats. This
227+
helps with course discovery and enables semantic web applications to understand
228+
your content. Available output formats are n-quads and JSON-LD.
229+
230+
Learn more:
231+
- RDF: https://www.w3.org/RDF/
232+
- N-Quads: https://www.w3.org/TR/n-quads/
233+
- JSON-LD: https://json-ld.org/
234+
235+
--rdf-format Output format n-quads, json-ld
236+
(defaults to json-ld).
237+
--rdf-preview Output the result to the console.
238+
--rdf-url Refer to an external URL when
239+
parsing a local project.
240+
--rdf-type Course frm schmema.org is applied as
241+
default, overwrite this with EducationalResource,
242+
etc.
243+
--rdf-license Add a license-URL, otherwise if url was
244+
provided as input, this will check for an existing
245+
LICENSE file.
246+
--rdf-educationalLevel Typically beginner, intermediate or advanced,
247+
and formal sets of level indicators.
248+
--rdf-template Use a URL or json-file as a template.
144249
```
145250
146251
### SCORM1.2

dist/index.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@liascript/exporter",
3-
"version": "2.6.37--0.16.11",
3+
"version": "2.6.38--0.16.11",
44
"description": "A generic exporter for LiaScript",
55
"main": "dist/index.js",
66
"repository": {

src/colorize.ts

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,86 @@ export function underline(text: string): string {
3030
export function command(
3131
short_command: string | null,
3232
long_command: string,
33-
description: string
33+
description: string,
34+
indentation: number = 28
3435
): undefined {
36+
// Format the command portion
37+
let commandPart = ''
38+
3539
if (short_command) {
36-
console.log(short(short_command), bold(long(long_command)), description)
40+
// Handle newline character if present in short_command
41+
if (short_command.includes('\n')) {
42+
commandPart =
43+
short(short_command.replace('\n', '')) + ' ' + bold(long(long_command))
44+
} else {
45+
commandPart = short(short_command) + ' ' + bold(long(long_command))
46+
}
3747
} else {
38-
console.log(bold(long(long_command)), description)
48+
commandPart = bold(long(long_command))
49+
}
50+
51+
// Get the visible length of the command part (without ANSI codes)
52+
const commandPartLength = commandPart.replace(/\x1b\[\d+m/g, '').length
53+
54+
// Calculate indentation padding
55+
const padding = Math.max(0, indentation - commandPartLength)
56+
57+
// Calculate available space for description after indentation
58+
const maxLineLength = 80 // Standard terminal width
59+
const wrapLength = maxLineLength - indentation
60+
61+
// Word wrap the description
62+
const words = description.split(' ')
63+
let lines = []
64+
let currentLine = ''
65+
66+
for (const word of words) {
67+
if ((currentLine + word).length > wrapLength && currentLine.length > 0) {
68+
lines.push(currentLine.trim())
69+
currentLine = word + ' '
70+
} else {
71+
currentLine += word + ' '
72+
}
73+
}
74+
75+
if (currentLine.trim().length > 0) {
76+
lines.push(currentLine.trim())
77+
}
78+
79+
// Output first line with proper indentation
80+
console.log(commandPart + ' '.repeat(padding) + lines[0])
81+
82+
// Output additional lines with consistent indentation
83+
for (let i = 1; i < lines.length; i++) {
84+
console.log(' '.repeat(indentation) + lines[i])
85+
}
86+
}
87+
88+
export function info(text: string, indentation: number = 0): void {
89+
// Calculate maximum line length
90+
const maxLineLength = 80
91+
const wrapLength = maxLineLength - indentation
92+
93+
// Word wrap the text
94+
const words = text.split(' ')
95+
let lines = []
96+
let currentLine = ''
97+
98+
for (const word of words) {
99+
if ((currentLine + word).length > wrapLength && currentLine.length > 0) {
100+
lines.push(currentLine.trim())
101+
currentLine = word + ' '
102+
} else {
103+
currentLine += word + ' '
104+
}
105+
}
106+
107+
if (currentLine.trim().length > 0) {
108+
lines.push(currentLine.trim())
109+
}
110+
111+
// Print each line with indentation and styling
112+
for (let i = 0; i < lines.length; i++) {
113+
console.log(' '.repeat(indentation) + italic(lines[i]))
39114
}
40115
}

0 commit comments

Comments
 (0)