Commit e8b9c102 authored by Ludan Stoecklé's avatar Ludan Stoecklé

1.5.5 real one this time

parent 0702b19e
......@@ -84,7 +84,8 @@ mixin phone_chunks
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......
'use strict';
let doctypes = require('doctypes');
let makeError = require('pug-error');
const doctypes = require('doctypes');
const makeError = require('pug-error');
//var buildRuntime = require('pug-runtime/build');
let runtime = require('pug-runtime');
let compileAttrs = require('pug-attrs');
const runtime = require('pug-runtime');
const compileAttrs = require('pug-attrs');
//var selfClosing = require('void-elements');
let constantinople = require('constantinople');
let stringify = require('js-stringify');
const constantinople = require('constantinople');
const stringify = require('js-stringify');
//var addWith = require('with');
//var debug = require('debug')('rosaenlg-yseop');
......@@ -104,7 +104,7 @@ Compiler.prototype = {
},
error: function(message, code, node) {
let err = makeError(code, message, {
const err = makeError(code, message, {
line: node.line,
column: node.column,
filename: node.filename,
......@@ -173,7 +173,7 @@ Compiler.prototype = {
// return js;
for (let name in this.mixins) {
for (const name in this.mixins) {
this.mixins[name] = this.mixins[name].join('\n');
}
......@@ -205,7 +205,7 @@ Compiler.prototype = {
*/
buffer: function(str) {
let self = this;
const self = this;
str = stringify(str);
str = str.substr(1, str.length - 2);
......@@ -279,7 +279,7 @@ Compiler.prototype = {
*/
visit: function(node, parent) {
let debug = this.debug;
const debug = this.debug;
if (!node) {
var msg;
......@@ -452,7 +452,7 @@ Compiler.prototype = {
this.pushWithIndent(`\\default`);
this.parentIndents++;
} else {
let newExpr = node.expr.replace(/^\'/, '"').replace(/\'$/, '"');
const newExpr = node.expr.replace(/^\'/, '"').replace(/\'$/, '"');
this.pushWithIndent(`\\case(${newExpr})`);
this.parentIndents++;
}
......@@ -484,8 +484,8 @@ Compiler.prototype = {
*/
visitBlock: function(block) {
let escapePrettyMode = this.escapePrettyMode;
let pp = this.pp;
const escapePrettyMode = this.escapePrettyMode;
const pp = this.pp;
// Pretty print multi-line text
if (
......@@ -551,11 +551,11 @@ Compiler.prototype = {
visitValue: function(rawArgs) {
// there should be 1 or 2 args
let firstComma = rawArgs.indexOf(',');
const firstComma = rawArgs.indexOf(',');
if (firstComma != -1) {
// 2 params (well most of the time)
let firstArg = trimAndReplaceQuotes(rawArgs.slice(0, firstComma));
let secondArg = rawArgs.slice(firstComma + 1);
const firstArg = trimAndReplaceQuotes(rawArgs.slice(0, firstComma));
const secondArg = rawArgs.slice(firstComma + 1);
let newArgs = [];
newArgs.push(firstArg);
......@@ -565,7 +565,11 @@ Compiler.prototype = {
if (mapped.matchedString) {
if (mapped.matchedString.indexOf('YYYY') > -1 || mapped.matchedString.indexOf('MM')) {
//console.log('is probably a date format');
const dateMappings = [['YYYY', '_DATE_YYYY'], ['MMMM', '_DATE_MMMM'], ['MM', '_DATE_MM']];
const dateMappings = [
['YYYY', '_DATE_YYYY'],
['MMMM', '_DATE_MMMM'],
['MM', '_DATE_MM'],
];
let leftParams = mapped.matchedString;
for (let i = 0; i < dateMappings.length; i++) {
const key = dateMappings[i][0];
......@@ -836,8 +840,8 @@ Compiler.prototype = {
visitVerb: function(rawArgs) {
// there should be 2 args
let firstComma = rawArgs.indexOf(',');
let subject = rawArgs.slice(0, firstComma).trim();
const firstComma = rawArgs.indexOf(',');
const subject = rawArgs.slice(0, firstComma).trim();
let secondArg = rawArgs.slice(firstComma + 1);
secondArg = secondArg.trim();
......@@ -902,7 +906,7 @@ Compiler.prototype = {
// args: 'arg1, arg2',
if (mixin.args) {
var args = mixin.args.split(',');
let yseopArgs = [];
const yseopArgs = [];
for (let i = 0; i < args.length; i++) {
yseopArgs.push('Object ' + args[i].trim());
}
......@@ -1137,7 +1141,7 @@ Compiler.prototype = {
this.pushWithIndent('/* TODO MIGRATE CODE');
this.parentIndents++;
let lines = code.val.split('\n');
const lines = code.val.split('\n');
for (let i = 0; i < lines.length; i++) {
this.pushWithIndent(lines[i]);
}
......@@ -1207,7 +1211,7 @@ Compiler.prototype = {
*/
visitWhile: function(loop) {
let test = loop.test;
const test = loop.test;
this.buf.push('while (' + test + ') {');
this.visit(loop.block, loop);
this.buf.push('}');
......@@ -1239,14 +1243,15 @@ Compiler.prototype = {
},
visitProtect: function(node) {
this.buf.push('pug_html = pug_html + "§";');
const msg = 'should be protected from automatic punctuation etc.';
this.pushWithIndent(`/* START ${msg} */`);
this.visit(node.block, node);
this.buf.push('pug_html = pug_html + "§";');
this.pushWithIndent(`/* END ${msg} */`);
},
visitRecordSaid: function(node) {
// in Yseop Symbols should be used vs strings in RosaeNLG
let val = node.val
const val = node.val
.replace(/\'/g, '')
.replace('(', '')
.replace(')', '');
......@@ -1255,7 +1260,7 @@ Compiler.prototype = {
},
visitDeleteSaid: function(node) {
let val = node.val
const val = node.val
.replace(/\'/g, '')
.replace('(', '')
.replace(')', '');
......@@ -1278,7 +1283,7 @@ Compiler.prototype = {
*/
visitEach: function(each) {
let foreach = `\\foreach(${each.val}, ${each.obj}) /* TODO MIGRATE foreach */`;
const foreach = `\\foreach(${each.val}, ${each.obj}) /* TODO MIGRATE foreach */`;
this.pushWithIndent(foreach);
this.parentIndents++;
......@@ -1297,7 +1302,7 @@ Compiler.prototype = {
visitAttributes: function(attrs, attributeBlocks) {
if (attributeBlocks.length) {
if (attrs.length) {
let val = this.attrs(attrs);
const val = this.attrs(attrs);
attributeBlocks.unshift(val);
}
if (attributeBlocks.length > 1) {
......@@ -1324,7 +1329,7 @@ Compiler.prototype = {
*/
attrs: function(attrs, buffer) {
let res = compileAttrs(attrs, {
const res = compileAttrs(attrs, {
terse: this.terse,
format: buffer ? 'html' : 'object',
runtime: this.runtime.bind(this),
......
......@@ -8,7 +8,7 @@ https://keepachangelog.com/en/0.3.0/
=== Changed
////
== [1.5.5] - 2019-12-12
== [1.5.5] - 2019-12-13
=== Added
......@@ -18,11 +18,12 @@ https://keepachangelog.com/en/0.3.0/
* the "missing space" issue, which lead to add lines with just `|` or `| #{''}`, is fixed (which is indeed a very good thing)
=== Changed
* *§...§ structure is deprecated*: please use `protect` tag instead which better cares for spacing
* in `rosaenlg-node-server`: removed `counter` in the response (didn't work properly, and was not really interesting)
== [1.5.4] - 2019-12-04
=== Added
......
......@@ -58,7 +58,7 @@ l unprotected.string
++++
will output _protected.string_ (and not _protected. String_).
TIP: `protectString(string)` is just a shortcut to `'§' + string + '§'`
TIP: You should favor the `protect` tag which better cares for spacing.
Use the `protect` tag to protect structures:
......
......@@ -368,14 +368,23 @@ spawnEditor(currentLang,
Néanmoins vous avez constaté que RosaeNLG a généré _L'OnePlus_, au lieu de _Le OnePlus_. RosaeNLG contient un mécanisme de contraction automatique (_le arbre_ devient _l'arbre_ etc.), mais qui se déclenche parfois de façon intempestive.
Protégez les noms de téléphone du mécanisme de contraction avec `§ ... §` :
Protégez les noms de téléphone du mécanisme de contraction avec `protect` :
....
syn
| le §#{phone.name}§ est vraiment un super téléphone.
| le
protect
| #{phone.name}
| est vraiment un super téléphone.
syn
| j'adore le nouveau #{phone.name}.
| j'adore le nouveau
protect
| #{phone.name}
| .
syn
| le §#{phone.name}§ : un super téléphone !
| le
protect
| #{phone.name}
| : un super téléphone !
....
Vous devriez à présent bien avoir _Le OnePlus 5T..._.
......@@ -386,11 +395,20 @@ const mixinIntro2String = `
mixin intro
synz
syn
| le §#{phone.name}§ est vraiment un super téléphone.
| le
protect
| #{phone.name}
| est vraiment un super téléphone.
syn
| j'adore le nouveau #{phone.name}.
| j'adore le nouveau
protect
| #{phone.name}
| .
syn
| le §#{phone.name}§ : un super téléphone !
| le
protect
| #{phone.name}
| : un super téléphone !
`;
spawnEditor(currentLang,
......@@ -550,7 +568,9 @@ En NLG (et en linguistique) ce concept est appelé _expressions référentielles
Créez 2 mixins, un pour chaque type de représentant :
....
mixin phone_ref(obj, params)
| le §#{phone.name}§
| le
protect
| #{phone.name}
mixin phone_refexpr(obj, params)
| #[+syn('ce téléphone', 'il')]
......@@ -600,7 +620,9 @@ const main3String = mainString.replace('MAIN',
const mixinPhoneRefRefexprString = `
mixin phone_ref(obj, params)
| le §#{phone.name}§
| le
protect
| #{phone.name}
mixin phone_refexpr(obj, params)
| #[+syn('ce téléphone', 'il')]
`;
......@@ -708,7 +730,8 @@ et exploitez-le :
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
....
TIP: La ligne vide contenant simplement un pipe `|` sert à forcer l'ajout d'un espace. Si vous ne le mettez pas, vous aurez _LeOnePlus_. Il est difficile de prévoir à l'avance ces cas - rajoutez simplement un `|` dans une ligne vide lorsqu'ils arrivent.
......@@ -721,7 +744,8 @@ const mixinPhoneRefRefexpr2String = `
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
mixin phone_refexpr(obj, params)
synz
......@@ -881,7 +905,8 @@ Nous devrions également expliciter le genre du représentant :
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
....
......@@ -900,7 +925,8 @@ const mixinPhoneRefRefexpr3String = `
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......@@ -956,7 +982,8 @@ const mixinPhoneRefRefexpr4String = `
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......@@ -1006,7 +1033,8 @@ const mixinPhoneRefRefexpr5String = `
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......@@ -1079,7 +1107,8 @@ const mixinPhoneRefRefexpr6String = `
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......
......@@ -63,7 +63,8 @@ mixin phone_chunks
mixin phone_ref(obj, params)
if !hasFlag(params,'NO_DET')
| le
| §#{phone.name}§
protect
| #{phone.name}
- setRefGender(phone, 'M')
mixin phone_refexpr(obj, params)
......
//- "|" around is to add spaces
//-------- foreach
mixin foreach(elts, mixinFct, asm, params)
|
- util.asmManager.foreach(elts, mixinFct, asm, params);
|
//-------- value
mixin value(obj, params)
|
- util.valueManager.value(obj, params);
|
//-------- filter
......@@ -28,7 +33,9 @@ mixin filter(mixinName, params)
//-------- syn
mixin syn(...items)
|
- util.synManager.simpleSyn(items);
|
-
function syn_fct(items) {
......@@ -39,20 +46,27 @@ mixin syn(...items)
//- test only: mising languages, irregulars etc.
mixin agreeAdj(adjective, subject, params)
|
- util.adjectiveManager.agreeAdj(adjective, subject, params);
|
//-------- substantive
mixin substantive(subst, subject)
|
| #{util.substantiveManager.getSubstantive(subst, subject, null)}
|
//-------- possessive
mixin recipientPossession(owned)
|
- util.possessiveManager.recipientPossession(owned);
|
mixin thirdPossession(owner, owned, params)
|
- util.possessiveManager.thirdPossession(owner, owned, params);
|
//- "|" around is to add spaces
mixin subjectVerb(subject, verbInfo, params)
|
- util.nominalGroupManager.subjectVerb(subject, verbInfo, params);
|
mixin subjectVerbAdj(subject, verbInfo, adjective, params)
|
- util.nominalGroupManager.subjectVerbAdj(subject, verbInfo, adjective, params);
|
mixin verb(subject, verbInfo)
|
| #{util.verbsManager.getAgreeVerb(subject, verbInfo)}
|
mixin verbPart()
|
| #{util.verbsManager.popVerbPart()}
|
......@@ -20,6 +20,10 @@ t
l a hour
l during a hour
l a Pharmaceuticals
l a §Pharmaceuticals§
l a §hour..long§
l a
protect
| Pharmaceuticals
l a
protect
| hour..long
l . a apple
......@@ -69,11 +69,14 @@ t
l
itemz {separator:',', last_separator: 'and'}
item
| §My Company Inc.§
protect
| My Company Inc.
item
| §My Other Company Ltd.§
protect
| My Other Company Ltd.
item
| §My Last Company & Co.§
protect
| My Last Company & Co.
l
- var params = { LAST_SEP_IS_ALT: false };
......
......@@ -20,6 +20,7 @@
February
2018
bla 562,407 bla
`;
......@@ -55,3 +56,7 @@ t
itemz {}
item
| #[+value( new Date(2018,01,1) , {dateFormat:'YYYY'})]
l
| bla #[+value(562407)] bla
......@@ -26,5 +26,6 @@ t
l #[+helper] / #[+helper] / #[+helper]
deleteValue('TEST')
l
| §!{getDumpHasSaid()}§
l
protect
| !{getDumpHasSaid()}
......@@ -6,6 +6,9 @@
protected.string bla.bla
protected.string bla.bla . bla
aaa.bbb
has bla toto
totototo
toto toto
`;
......@@ -14,7 +17,8 @@ mixin amixin
t
l
| §protected.string§
protect
| protected.string
l #{protectString("protected.string")}
l
......@@ -30,3 +34,13 @@ t
l
protect
| aaa.bbb
l
+verb(getAnonMS(), {verb:'have'})
+syn('bla','bla')
+value('toto')
l
| #{'toto'}#{'toto'}
l
| #{'toto'} #{'toto'}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment