Skip to content

Commit

Permalink
#232: updated kip.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kray-G committed Aug 20, 2021
1 parent 647a778 commit 3dcd17e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
7 changes: 2 additions & 5 deletions lib/exec/kip.kx
Original file line number Diff line number Diff line change
Expand Up @@ -752,18 +752,15 @@ class KinxPackageLibraryManager(repoMgr_) {
return false;
}
createFile(PACKAGE_INFO_FILE, { name: name }.toJsonString(true));
var license = File.exists("LICENSE") ? ("```\n" + File.load("LICENSE").trim() + "\n```\n") : "You must";
mkdir("docs", "README.md",
"<!-- This is an auto-generated sample README file. Modify this as your own README file. -->\n"
"# Kacc\n\n"
"## Introduction\n\n"
"This is a directory of documents for the package `%{name}` such as materials below.\n\n"
"- Package Help - this `README.md` will be displayed by `kip help %{name}`\n"
"- User Guide\n"
"- API documents\n\n"
"Kindly provide the documents for users.\n\n"
"# License\n\n"
"This package is published under the following license.\n\n"
"%{license}",
"Kindly provide the documents for users.",
"a default README file");
mkdir("src/bin", "%{name}.kx",
"# This is a sample hook script file. Feel free to modify this, and it'll be an executable automatically.\n"
Expand Down
30 changes: 24 additions & 6 deletions lib/std/MarkdownConsole.kx
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,21 @@ class MarkdownConsole(mdtext_) {
const romanKey_ = ["","c","cc","ccc","cd","d","dc","dcc","dccc","cm","","x","xx","xxx","xl","l","lx","lxx","lxxx","xc","","i","ii","iii","iv","v","vi","vii","viii","ix"];
const romanKeyCap_ = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"];
const bullet_ = ['*', '-', '+'];
var nl_ = 0;

private newline(cond) {
if (cond()) {
System.println("");
++nl_;
} else {
nl_ = 0;
}
}

public heading(item) {
System.println("");
if (newline({ => true })) {
System.println("");
}
var level = item.level;
var text = inline_.makeInlineText(item.values);
switch (level) {
Expand All @@ -135,8 +147,14 @@ class MarkdownConsole(mdtext_) {
}
}
public paragraph(item) {
System.println("");
System.println(inline_.makeInlineText(item.values));
var text = inline_.makeInlineText(item.values);
if (text.trim() == "") {
return;
}
if (newline({ => prev_ != "paragraph" })) {
System.println("");
}
System.println(text);
}
private isList(p) {
return p == "list" || p == "orderedlist" || p == "checklist";
Expand All @@ -147,7 +165,7 @@ class MarkdownConsole(mdtext_) {
}
}
public list(item) {
if (!isList(prev_)) {
if (newline({ => !isList(prev_) })) {
count_ = [0, 0, 0, 0, 0, 0];
System.println("");
}
Expand All @@ -172,7 +190,7 @@ class MarkdownConsole(mdtext_) {
return ("M" * Integer.parseInt(digits.join(""))) + roman + ".";
};
public orderedlist(item) {
if (!isList(prev_)) {
if (newline({ => !isList(prev_) })) {
count_ = [0, 0, 0, 0, 0, 0];
System.println("");
}
Expand Down Expand Up @@ -213,7 +231,7 @@ class MarkdownConsole(mdtext_) {
System.println(inline_.makeInlineText(item.values));
}
public checklist(item) {
if (!isList(prev_)) {
if (newline({ => !isList(prev_) })) {
count_ = [0, 0, 0, 0, 0, 0];
System.println("");
}
Expand Down

0 comments on commit 3dcd17e

Please sign in to comment.