Closed codepiano closed 10 years ago
Thanks :+1:
@AaronO actually,the deep reason is the lodash funtion 'toArray' in gitbook's search_index.js, it will cast object
{ '0': { type: 'heading', depth: 1, text: 'Article' },
'1': { type: 'paragraph', text: 'test' },
type: 'normal',
id: 'gitbook_1',
links: {} }
to
[{"type":"heading","depth":1,"text":"Article"},{"type":"paragraph","text":"test"},"normal","gitbook_1",{}]
so when the last three values 'normal','gitbook_1' and {} is processed by the tok() function,will produce 'undefined'. I think maybe there is a better way to fix this,avoid to add these attrubutes to the array,but I am not familiar with the data flow,so just add code to ignore these in tok().
empty objects and plain strings in variable 'this.tokens' will result in additional 'undefined' string in the output of the 'Parser.prototype.parse' function.It will pollute the search_index.json, product a lot of 'undefinedundefined...' index.