start parsing headers of org file counts

This commit is contained in:
Tykayn 2023-03-01 17:17:48 +01:00 committed by tykayn
parent 7dd2b8e86b
commit 01e7a56dc2
3 changed files with 278 additions and 10 deletions

View File

@ -16,13 +16,52 @@ fs.readFile(input_orgmode_file_name, 'utf8', function read(err, data) {
var parser = new org.Parser();
var orgDocument = parser.parse(org_content);
console.log('le fichier input.org a ce nombre de');
console.log(' SOMEDAY:', org_content.toString().match(/SOMEDAY/g)?.length);
console.log(' TODO:', org_content.toString().match(/TODO/g)?.length);
console.log(' NEXT:', org_content.toString().match(/NEXT/g)?.length);
console.log(' CANCELLED:', org_content.toString().match(/CANCELLED/g)?.length);
console.log(' DONE:', org_content.toString().match(/DONE/g)?.length);
// console.log('orgDocument', orgDocument)
orgDocument.nodes.forEach(node => {
if (node.type === 'header') {
console.log('header')
searchForChildren(node)
}
})
console.log('headerTexts', headerTexts);
let all_headers = headerTexts.join('\n')
console.log('le fichier input.org a ce nombre de type de tâches');
console.log(' SOMEDAY:', all_headers.toString().match(/SOMEDAY/g)?.length);
console.log(' TODO:', all_headers.toString().match(/TODO/g)?.length);
console.log(' NEXT:', all_headers.toString().match(/NEXT/g)?.length);
console.log(' CANCELLED:', all_headers.toString().match(/CANCELLED/g)?.length);
console.log(' DONE:', all_headers.toString().match(/DONE/g)?.length);
});
let headerTexts = []
function logTextOfNode(node) {
if (node.value && node.type==='text') {
console.log(' -- ', node.value)
headerTexts.push(node.value)
}
}
function searchForChildren(node) {
logTextOfNode(node)
if (node.children) {
node.children.forEach(child => {
console.log(' -- ', child)
searchForChildren(child)
})
}
}
// trouver les propriétés de date de cloture pour grouper les tâches par section de temps
// afin de savoir ce qui a été réalisé ces X derniers jours
let interval_report_days = 30;

View File

@ -1,11 +1,13 @@
* des choses
** TODO faire un truc
CLOSED: [2023-03-01 mer. 10:42]
une tâche de niveau 2 sans tag, properties ni logbook
** TODO faire un autre truc :autre:
CLOSED: [2023-02-01 mer. 10:42]
:LOGBOOK:
- State "CANCELLED" from "TODO" [2023-02-28 mar. 11:50]
:END:
ya du logbook ici wohoo
*** SOMEDAY avoir une idée :idea:
** CANCELLED envoyer un justificatif médical :ARCHIVE:
**** CANCELLED envoyer un justificatif médical :ARCHIVE:
héééééé oui le texte de note

View File

@ -1,6 +1,233 @@
le fichier input.org a ce nombre de
header
-- <ref *1> {
type: 'inlineContainer',
children: [
{
type: 'text',
children: [],
value: 'des choses',
previousSibling: null,
parent: [Circular *1]
}
],
previousSibling: null,
parent: {
type: 'header',
children: [ [Circular *1] ],
level: 1,
fromLineNumber: 1,
previousSibling: null
}
}
-- <ref *1> {
type: 'text',
children: [],
value: 'des choses',
previousSibling: null,
parent: {
type: 'inlineContainer',
children: [ [Circular *1] ],
previousSibling: null,
parent: {
type: 'header',
children: [Array],
level: 1,
fromLineNumber: 1,
previousSibling: null
}
}
}
-- des choses
header
-- <ref *1> {
type: 'inlineContainer',
children: [
{
type: 'text',
children: [],
value: 'TODO faire un truc',
previousSibling: null,
parent: [Circular *1]
}
],
previousSibling: null,
parent: {
type: 'header',
children: [ [Circular *1] ],
level: 2,
fromLineNumber: 2,
previousSibling: {
type: 'header',
children: [Array],
level: 1,
fromLineNumber: 1,
previousSibling: null
}
}
}
-- <ref *1> {
type: 'text',
children: [],
value: 'TODO faire un truc',
previousSibling: null,
parent: {
type: 'inlineContainer',
children: [ [Circular *1] ],
previousSibling: null,
parent: {
type: 'header',
children: [Array],
level: 2,
fromLineNumber: 2,
previousSibling: [Object]
}
}
}
-- TODO faire un truc
header
-- <ref *1> {
type: 'inlineContainer',
children: [
{
type: 'text',
children: [],
value: 'TODO faire un autre truc :autre:',
previousSibling: null,
parent: [Circular *1]
}
],
previousSibling: null,
parent: {
type: 'header',
children: [ [Circular *1] ],
level: 2,
fromLineNumber: 4,
previousSibling: {
type: 'inlineContainer',
children: [Array],
previousSibling: [Object]
}
}
}
-- <ref *1> {
type: 'text',
children: [],
value: 'TODO faire un autre truc :autre:',
previousSibling: null,
parent: {
type: 'inlineContainer',
children: [ [Circular *1] ],
previousSibling: null,
parent: {
type: 'header',
children: [Array],
level: 2,
fromLineNumber: 4,
previousSibling: [Object]
}
}
}
-- TODO faire un autre truc :autre:
header
-- <ref *1> {
type: 'inlineContainer',
children: [
{
type: 'text',
children: [],
value: 'SOMEDAY avoir une idée :idea:',
previousSibling: null,
parent: [Circular *1]
}
],
previousSibling: null,
parent: {
type: 'header',
children: [ [Circular *1] ],
level: 3,
fromLineNumber: 9,
previousSibling: {
type: 'inlineContainer',
children: [Array],
previousSibling: [Object]
}
}
}
-- <ref *1> {
type: 'text',
children: [],
value: 'SOMEDAY avoir une idée :idea:',
previousSibling: null,
parent: {
type: 'inlineContainer',
children: [ [Circular *1] ],
previousSibling: null,
parent: {
type: 'header',
children: [Array],
level: 3,
fromLineNumber: 9,
previousSibling: [Object]
}
}
}
-- SOMEDAY avoir une idée :idea:
header
-- <ref *1> {
type: 'inlineContainer',
children: [
{
type: 'text',
children: [],
value: 'CANCELLED envoyer un justificatif médical :ARCHIVE:',
previousSibling: null,
parent: [Circular *1]
}
],
previousSibling: null,
parent: {
type: 'header',
children: [ [Circular *1] ],
level: 4,
fromLineNumber: 10,
previousSibling: {
type: 'header',
children: [Array],
level: 3,
fromLineNumber: 9,
previousSibling: [Object]
}
}
}
-- <ref *1> {
type: 'text',
children: [],
value: 'CANCELLED envoyer un justificatif médical :ARCHIVE:',
previousSibling: null,
parent: {
type: 'inlineContainer',
children: [ [Circular *1] ],
previousSibling: null,
parent: {
type: 'header',
children: [Array],
level: 4,
fromLineNumber: 10,
previousSibling: [Object]
}
}
}
-- CANCELLED envoyer un justificatif médical :ARCHIVE:
headerTexts [
'des choses',
'TODO faire un truc',
'TODO faire un autre truc :autre:',
'SOMEDAY avoir une idée :idea:',
'CANCELLED envoyer un justificatif médical :ARCHIVE:'
]
le fichier input.org a ce nombre de type de tâches
SOMEDAY: 1
TODO: 3
TODO: 2
NEXT: undefined
CANCELLED: 2
CANCELLED: 1
DONE: undefined