Skip to content

Commit

Permalink
Publish v0.4.0 [#27]
Browse files Browse the repository at this point in the history
  • Loading branch information
davidstraka2 committed Apr 20, 2021
1 parent c8e88bb commit d7a43e4
Show file tree
Hide file tree
Showing 170 changed files with 3,741 additions and 50 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] (2021-04-20)

### Added

- Support for math rendering in live preview [[#25], [#26]]
- Live HTML preview of WooWoo documents [[#26]]
- Basic HTML rendering of most WooWoo elements [[#25]]
- Complete parsing of valid WooWoo documents [[#24]]
- Support for the "Editor: Toggle Line Comments" command [[#23]]

### Changed

- Minor WooWoo grammar improvements regarding indentation for better syntax
highlighting [[#22]]

### Removed

- The `demoView` command [[#26]]

## [0.3.0] (2021-03-16)

### Added
Expand Down Expand Up @@ -48,9 +67,15 @@ and this project adheres to
- Set up linting with ESLint (and typescript-eslint/eslint-plugin) [[#10]]
- Set up CI using GitHub Actions [[#6], [#7], [#9], [#11]]

[0.4.0]: https://github.com/davidstraka2/wootom/compare/v0.3.0-src...v0.4.0-src
[0.3.0]: https://github.com/davidstraka2/wootom/compare/v0.2.0-src...v0.3.0-src
[0.2.0]: https://github.com/davidstraka2/wootom/compare/v0.1.0-src...v0.2.0-src
[0.1.0]: https://github.com/davidstraka2/wootom/releases/tag/v0.1.0-src
[#26]: https://github.com/davidstraka2/wootom/issues/26
[#25]: https://github.com/davidstraka2/wootom/issues/25
[#24]: https://github.com/davidstraka2/wootom/issues/24
[#23]: https://github.com/davidstraka2/wootom/issues/23
[#22]: https://github.com/davidstraka2/wootom/issues/22
[#21]: https://github.com/davidstraka2/wootom/issues/21
[#19]: https://github.com/davidstraka2/wootom/issues/19
[#18]: https://github.com/davidstraka2/wootom/issues/18
Expand Down
4 changes: 2 additions & 2 deletions grammars/woo.cson
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ patterns: [

repository:
inlineComment: {
match: '(?<!%)%.*'
match: '^%.*'
name: 'comment.line.woo'
}
partHeading: {
begin: '^\\s*(\\.)([A-Z]\\w*)[^\\S\\r\\n]+(.+)'
begin: '^(\\.)([A-Z]\\w*)[^\\S\\r\\n]+(.+)'
beginCaptures:
1: name: 'keyword.operator.foo'
2: name: 'markup.heading.foo'
Expand Down
5 changes: 5 additions & 0 deletions keymaps/wootom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"atom-workspace": {
"alt-n": "wootom:togglePreview"
}
}
33 changes: 33 additions & 0 deletions lib/core/ast/ast-node-position.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** The position of an ASTNode relative to the source document */
export declare class ASTNodePosition {
/**
* Get the position of the end of a text
*
* @param start The position of the start of the input text
* @param value The input text
* @returns The position of the end of the input text
*/
static getEnd(start: ASTNodePosition, value: string): ASTNodePosition;
/**
* The line/row position relative to the source document (indexed from 1)
*/
line: number;
/** The column position relative to the source document, indexed from 1 */
column: number;
/**
* The offset/character position relative to the source document, indexed
* from 0
*/
offset: number;
/**
* @param line The line/row position relative to the source document
* (indexed from 1)
* @param column The column position relative to the source document,
* indexed from 1
* @param offset The offset/character position relative to the source
* document, indexed from 0
*/
constructor(line: number, column: number, offset: number);
/** @param source The source `ASTNodePosition` object to copy */
constructor(source: ASTNodePosition);
}
41 changes: 41 additions & 0 deletions lib/core/ast/ast-node-position.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ASTNodePosition = void 0;
const multiline_1 = require("../../util/text/multiline");
/** The position of an ASTNode relative to the source document */
class ASTNodePosition {
constructor(lineOrSource, column, offset) {
if (typeof lineOrSource === 'object') {
this.line = lineOrSource.line;
this.column = lineOrSource.column;
this.offset = lineOrSource.offset;
}
else {
this.line = lineOrSource;
this.column = column;
this.offset = offset;
}
}
/**
* Get the position of the end of a text
*
* @param start The position of the start of the input text
* @param value The input text
* @returns The position of the end of the input text
*/
static getEnd(start, value) {
const linecount = multiline_1.countLines(value);
const end = new ASTNodePosition(start);
end.offset += value.length;
if (linecount > 1) {
const lastLine = multiline_1.getLastLine(value);
end.column = 1 + lastLine.length;
end.line += linecount - 1;
}
else {
end.column += value.length;
}
return end;
}
}
exports.ASTNodePosition = ASTNodePosition;
89 changes: 89 additions & 0 deletions lib/core/ast/ast-node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { JSONMap } from '../../util/types/json';
import { WooElementKind } from '../../util/types/woo';
import { ASTNodePosition } from './ast-node-position';
/** A node of an abstract syntax tree representing a WooWoo document */
export declare abstract class ASTNode {
/** The kind/type of the node */
abstract kind: WooElementKind;
/** Whether the node is fragile (`true` if it is) */
abstract isFragile: boolean;
/** The parent node of the node */
abstract parent?: ASTNode;
/**
* The line/row position of the start of the node relative to the source
* document (indexed from 1)
*/
readonly startLine: number;
/**
* The column position of the start of the node relative to the source
* document (indexed from 1)
*/
readonly startColumn: number;
/**
* The offset/character position of the start of the node relative to the
* source document (indexed from 0)
*/
readonly startOffset: number;
/**
* The line/row position of the end of the node relative to the source
* document (indexed from 1)
*/
readonly endLine: number;
/**
* The column position of the end of the node relative to the source
* document (indexed from 1)
*/
readonly endColumn: number;
/**
* The offset/character position of the start of the node relative to the
* source document (indexed from 0)
*/
readonly endOffset: number;
/** The child nodes of the node */
private _children;
/** The metadata items of the node */
private metadata;
constructor(start: ASTNodePosition, end: ASTNodePosition);
/** The children of this node */
get children(): ASTNode[];
/** The position of end of the node */
get end(): ASTNodePosition;
/** The position of start of the node */
get start(): ASTNodePosition;
/**
* Add nodes as children of this node.
*
* The children are appended sequentially (so the first node given is also
* the first to be appended) after any existing children.
*
* @param children The nodes to add as children of this node
*/
addChildren(...children: ASTNode[]): this;
/**
* Retrieve a metadata item value by its key
*
* @param key The key of the item to be retrieved
* @returns The retrieved item value
*/
getMetadata(key: string): unknown;
/**
* Set a metadata item value by its key
*
* @param key The key of the item to be set
* @param value The value of the item to be set
*/
setMetadata(key: string, value: unknown): this;
/**
* Checks whether two nodes are equal (this is a deep comparison)
*
* @param otherASTNode The other node to check against
* @returns Whether the two nodes are (deep) equal
*/
equals(otherASTNode: ASTNode): boolean;
/**
* Get a valid JSON value representing the node
*
* @returns A JSON value representing the node
*/
toJSON(): JSONMap;
}
94 changes: 94 additions & 0 deletions lib/core/ast/ast-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ASTNode = void 0;
const lodash_1 = require("lodash");
const ast_node_position_1 = require("./ast-node-position");
/** A node of an abstract syntax tree representing a WooWoo document */
class ASTNode {
constructor(start, end) {
/** The child nodes of the node */
this._children = [];
/** The metadata items of the node */
this.metadata = {};
this.startLine = start.line;
this.startColumn = start.column;
this.startOffset = start.offset;
this.endLine = end.line;
this.endColumn = end.column;
this.endOffset = end.offset;
}
/** The children of this node */
get children() {
return this._children;
}
/** The position of end of the node */
get end() {
return new ast_node_position_1.ASTNodePosition(this.endLine, this.endColumn, this.endOffset);
}
/** The position of start of the node */
get start() {
return new ast_node_position_1.ASTNodePosition(this.startLine, this.startColumn, this.startOffset);
}
/**
* Add nodes as children of this node.
*
* The children are appended sequentially (so the first node given is also
* the first to be appended) after any existing children.
*
* @param children The nodes to add as children of this node
*/
addChildren(...children) {
this.children.push(...children);
return this;
}
/**
* Retrieve a metadata item value by its key
*
* @param key The key of the item to be retrieved
* @returns The retrieved item value
*/
getMetadata(key) {
return this.metadata[key];
}
/**
* Set a metadata item value by its key
*
* @param key The key of the item to be set
* @param value The value of the item to be set
*/
setMetadata(key, value) {
this.metadata[key] = value;
return this;
}
/**
* Checks whether two nodes are equal (this is a deep comparison)
*
* @param otherASTNode The other node to check against
* @returns Whether the two nodes are (deep) equal
*/
equals(otherASTNode) {
if (this === otherASTNode)
return true;
return lodash_1.isEqual(this.toJSON(), otherASTNode.toJSON());
}
/**
* Get a valid JSON value representing the node
*
* @returns A JSON value representing the node
*/
toJSON() {
return {
kind: this.kind,
isFragile: this.isFragile,
startLine: this.startLine,
startColumn: this.startColumn,
startOffset: this.startOffset,
endLine: this.endLine,
endColumn: this.endColumn,
endOffset: this.endOffset,
children: this.children.map(child => child.toJSON()),
metadata: JSON.parse(JSON.stringify(this.metadata)),
};
}
}
exports.ASTNode = ASTNode;
18 changes: 18 additions & 0 deletions lib/core/ast/document-object.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ASTNode } from './ast-node';
import { ASTNodePosition } from './ast-node-position';
import { VariableASTNode } from './variable-ast-node';
/** A variable ASTNode representing a document object */
export declare class DocumentObject extends VariableASTNode {
readonly variant: string;
readonly isFragile: boolean;
readonly parent?: ASTNode | undefined;
readonly kind = "DocumentObject";
/**
* @param variant The variant of the node
* @param isFragile Whether the node is fragile (`true` if it is)
* @param start The position of the start of the node
* @param end The position of the end of the node
* @param parent The parent node of the node
*/
constructor(variant: string, isFragile: boolean, start: ASTNodePosition, end: ASTNodePosition, parent?: ASTNode | undefined);
}
22 changes: 22 additions & 0 deletions lib/core/ast/document-object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentObject = void 0;
const variable_ast_node_1 = require("./variable-ast-node");
/** A variable ASTNode representing a document object */
class DocumentObject extends variable_ast_node_1.VariableASTNode {
/**
* @param variant The variant of the node
* @param isFragile Whether the node is fragile (`true` if it is)
* @param start The position of the start of the node
* @param end The position of the end of the node
* @param parent The parent node of the node
*/
constructor(variant, isFragile, start, end, parent) {
super(start, end);
this.variant = variant;
this.isFragile = isFragile;
this.parent = parent;
this.kind = 'DocumentObject';
}
}
exports.DocumentObject = DocumentObject;
17 changes: 17 additions & 0 deletions lib/core/ast/document-part.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ASTNode } from './ast-node';
import { ASTNodePosition } from './ast-node-position';
import { VariableASTNode } from './variable-ast-node';
/** A variable ASTNode representing a document part */
export declare class DocumentPart extends VariableASTNode {
readonly variant: string;
readonly parent?: ASTNode | undefined;
readonly kind = "DocumentPart";
readonly isFragile = false;
/**
* @param variant The variant of the node
* @param start The position of the start of the node
* @param end The position of the end of the node
* @param parent The parent node of the node
*/
constructor(variant: string, start: ASTNodePosition, end: ASTNodePosition, parent?: ASTNode | undefined);
}
Loading

0 comments on commit d7a43e4

Please sign in to comment.