@ca-plant-list/ca-plant-list 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/families.js CHANGED
@@ -1,8 +1,8 @@
1
- import * as fs from "node:fs";
2
1
  import { HTMLPage } from "./htmlpage.js";
3
2
  import { HTML } from "./html.js";
4
3
  import { Jepson } from "./jepson.js";
5
4
  import { Taxa } from "./taxa.js";
5
+ import { Files } from "./files.js";
6
6
 
7
7
  class Families {
8
8
 
@@ -13,7 +13,7 @@ class Families {
13
13
  }
14
14
 
15
15
  static init( dataDir ) {
16
- this.#families = JSON.parse( fs.readFileSync( dataDir + "/families.json" ) );
16
+ this.#families = JSON.parse( Files.read( dataDir + "/families.json" ) );
17
17
  for ( const [ k, v ] of Object.entries( this.#families ) ) {
18
18
  this.#families[ k ] = new Family( k, { id: v } );
19
19
  }
package/lib/html.js CHANGED
@@ -57,6 +57,11 @@ export class HTML {
57
57
  return html + ">" + this.escapeText( linkText ) + "</a >";
58
58
  }
59
59
 
60
+ static getToolTip( text, tooltip ) {
61
+ const func = text.charAt( 0 ) === "<" ? HTML.wrap : HTML.textElement;
62
+ return func( "span", text + " ⓘ", { title: tooltip } );
63
+ }
64
+
60
65
  static renderAttribute( n, v ) {
61
66
  return " " + n + "=\"" + this.escapeAttribute( v ) + "\"";
62
67
  }
@@ -70,11 +75,11 @@ export class HTML {
70
75
  }
71
76
 
72
77
  static textElement( elName, text, attributes = {} ) {
73
- return this.#getElement( elName, text, attributes, true );
78
+ return HTML.#getElement( elName, text, attributes, true );
74
79
  }
75
80
 
76
81
  static wrap( elName, text, attributes = {} ) {
77
- return this.#getElement( elName, text, attributes, false );
82
+ return HTML.#getElement( elName, text, attributes, false );
78
83
  }
79
84
 
80
85
  }
package/lib/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export class HTML {
22
22
  static getElement(elName: any, text: any, attributes?: {}, options?: number): string;
23
23
  static "__#2@#getElement"(elName: any, text: any, attributes: any, escape: any): string;
24
24
  static getLink(href: any, linkText: any, attributes?: {}, options?: number): string;
25
+ static getToolTip(text: any, tooltip: any): string;
25
26
  static renderAttribute(n: any, v: any): string;
26
27
  static renderAttributes(attributes: any): string;
27
28
  static textElement(elName: any, text: any, attributes?: {}): string;
package/lib/index.js CHANGED
@@ -4,10 +4,11 @@ import { CSV } from "./csv.js";
4
4
  import { DataLoader } from "./dataloader.js";
5
5
  import { ErrorLog } from "./errorlog.js";
6
6
  import { Exceptions } from "./exceptions.js";
7
+ import { Families } from "./families.js";
7
8
  import { Files } from "./files.js";
8
9
  import { HTML, HTML_OPTIONS } from "./html.js";
9
10
  import { Jekyll } from "./jekyll.js";
10
11
  import { Taxa } from "./taxa.js";
11
12
  import { Taxon } from "./taxon.js";
12
13
 
13
- export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Files, HTML, HTML_OPTIONS, Jekyll, Taxa, Taxon };
14
+ export { BasePageRenderer, Config, CSV, DataLoader, ErrorLog, Exceptions, Families, Files, HTML, HTML_OPTIONS, Jekyll, Taxa, Taxon };
package/lib/jekyll.js CHANGED
@@ -7,7 +7,8 @@ class Jekyll {
7
7
  }
8
8
 
9
9
  static include( path ) {
10
- return "{%include " + path + "%}";
10
+ // This works for .md includes; should have conditional logic to detect other types.
11
+ return "{% capture my_include %}{% include " + path + " %}{% endcapture %}{{ my_include | markdownify }}";
11
12
  }
12
13
 
13
14
  static writeInclude( baseDir, path, data ) {
package/lib/taxon.js CHANGED
@@ -47,6 +47,11 @@ class Taxon {
47
47
  }
48
48
  }
49
49
 
50
+ getBaseFileName() {
51
+ // Convert spaces to "-" and remove ".".
52
+ return this.#name.replaceAll( " ", "-" ).replaceAll( ".", "" );
53
+ }
54
+
50
55
  getCalfloraName() {
51
56
  if ( this.#cfSyn ) {
52
57
  return this.#cfSyn;
@@ -83,13 +88,8 @@ class Taxon {
83
88
  return Genera.getFamily( this.#genus );
84
89
  }
85
90
 
86
- getFileName( ext ) {
87
- return Taxon.getFileName( this.getName(), ext );
88
- }
89
-
90
- static getFileName( name, ext = "html" ) {
91
- // Convert spaces to "-" and remove ".".
92
- return name.replaceAll( " ", "-" ).replaceAll( ".", "" ) + "." + ext;
91
+ getFileName( ext = "html" ) {
92
+ return this.getBaseFileName() + "." + ext;
93
93
  }
94
94
 
95
95
  getGenus() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {