Skip to content

Commit

Permalink
feat: Crosslinking with any section using custom-heading-ids (#122)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: affects **v5.0.0-alpha.0** or **v5.0.0-alpha.1**, only. 
Renamed option `linking.terms` to `linking.mentions`. Please rename the
option in your config file.

fix: Being more robust if no glossary file is available.
chore(docs): Show preferred --init command for installation method
chore(upgrade): Make sure to only upgrade to versions compatible with default schema

test: New baseline.
  • Loading branch information
about-code committed Dec 21, 2020
1 parent e89f99e commit 949c815
Show file tree
Hide file tree
Showing 112 changed files with 533 additions and 558 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,17 @@

```
npm i -g glossarify-md
```
```
glossarify-md --init > glossarify-md.conf.json
glossarify-md --config ./glossarify-md.conf.json
```

#### Option 2: Install locally as a project dependency:

```
npm i glossarify-md
```
```
npx glossarify-md --local --init > glossarify-md.conf.json
npx glossarify-md --config ./glossarify-md.conf.json
```

Expand Down Expand Up @@ -709,12 +707,12 @@ In most situations, e.g. when hosting markdown files in a repository or
processing markdown files with an MD to HTML converter omitting a pre-defined
`baseUrl` and using `linking.paths: "relative"` is likely to work better.

#### `linking.terms`
#### `linking.mentions`

- **Range:** `"all" | "first-in-paragraph"`
- **Since:** v5.0.0

By default every occurrence of a term will be linkified. Sometimes this can
By default every mention of a term will be linkified. Sometimes this can
result in too much links affecting readability. This option provides finer
control of linkify behavior.

Expand Down
25 changes: 19 additions & 6 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require("path");
const proc = require("process");
const program = require("../lib/main");
const upgrade = require("../lib/cli/upgrade");
const confSchema = require("../conf/v5/schema.json").properties;
const confSchema = require("../conf/v5/schema.json");
const {NO_BASEDIR, NO_OUTDIR, OUTDIR_IS_BASEDIR, OUTDIR_IS_BASEDIR_WITH_DROP} = require("../lib/cli/messages");
const {version} = require("../package.json");
const CWD = proc.cwd();
Expand All @@ -24,6 +24,12 @@ const cli = {
,type: "boolean"
,default: false
}
,"local": {
alias: ""
,description: "When used with --init generates a configuration using a local node_modules path to the config schema."
,type: "boolean"
,default: false
}
,"config": {
alias: "c"
,description: "Path to config file, e.g. './glossarify-md.conf.json'."
Expand Down Expand Up @@ -62,6 +68,13 @@ if (argv.help || proc.argv.length === 2) {
}

// --config
const confSchemaProps = confSchema.properties;
const confDefault = Object
.keys(confSchemaProps)
.reduce((obj, key) => {
obj[key] = confSchemaProps[key].default;
return obj;
}, { "$schema": confSchema.$id });
let confDir = "";
let confPath = argv.config || "";
let confData = {};
Expand All @@ -72,7 +85,7 @@ if (confPath) {
confDir = path.dirname(confPath);
confData = JSON.parse(fs.readFileSync(confPath));
if (!argv.noupgrade) {
confPromise = upgrade(confData, confPath);
confPromise = upgrade(confData, confPath, confDefault);
}
} catch (e) {
console.error(`Failed to read config '${confPath}'.\nReason:\n ${e.message}\n`);
Expand Down Expand Up @@ -103,10 +116,6 @@ confPromise.then((conf) => {
}
}
// Merge custom conf with default conf
const confDefault = Object.keys(confSchema).reduce((obj, key) => {
obj[key] = confSchema[key].default;
return obj;
}, {});
conf = merge(confDefault, conf, {
clone: false
, arrayMerge: (_default, curConf) => {
Expand All @@ -116,6 +125,10 @@ confPromise.then((conf) => {

// --init
if (argv.init) {
if (argv.local) {
// append version path segment from schema URI to local path
conf.$schema = `./node_modules/glossarify-md/conf/${conf.$schema.split("/conf/")[1]}`;
}
console.log(JSON.stringify(conf, null, 2));
proc.exit(0);
}
Expand Down
269 changes: 0 additions & 269 deletions conf.schema.json

This file was deleted.

Loading

0 comments on commit 949c815

Please sign in to comment.