MCPcopy
hub / github.com/benweet/stackedit / parseContent

Method parseContent

src/services/providers/common/Provider.js:46–78  ·  view source on GitHub ↗

* Parse content serialized with serializeContent()

(serializedContent, id)

Source from the content-addressed store, hash-verified

44 * Parse content serialized with serializeContent()
45 */
46 static parseContent(serializedContent, id) {
47 let text = serializedContent;
48 const extractedData = dataExtractor.exec(serializedContent);
49 let result;
50 if (!extractedData) {
51 // In case stackedit's data has been manually removed, try to restore them
52 result = utils.deepCopy(store.state.content.itemsById[id]) || emptyContent(id);
53 } else {
54 result = emptyContent(id);
55 try {
56 const serializedData = extractedData[1].replace(/\s/g, '');
57 const parsedData = JSON.parse(utils.decodeBase64(serializedData));
58 text = text.slice(0, extractedData.index);
59 if (parsedData.properties) {
60 result.properties = utils.sanitizeText(parsedData.properties);
61 }
62 if (parsedData.discussions) {
63 result.discussions = parsedData.discussions;
64 }
65 if (parsedData.comments) {
66 result.comments = parsedData.comments;
67 }
68 result.history = parsedData.history;
69 } catch (e) {
70 // Ignore
71 }
72 }
73 result.text = utils.sanitizeText(text);
74 if (!result.history) {
75 result.history = [];
76 }
77 return utils.addItemHash(result);
78 }
79
80 /**
81 * Find and open a file with location that meets the criteria

Callers 15

downloadWorkspaceContentFunction · 0.80
getFileRevisionContentFunction · 0.80
downloadContentFunction · 0.80
getFileRevisionContentFunction · 0.80
downloadContentFunction · 0.80
getFileRevisionContentFunction · 0.80
downloadContentFunction · 0.80
getFileRevisionContentFunction · 0.80
downloadContentFunction · 0.80
getFileRevisionContentFunction · 0.80
downloadWorkspaceContentFunction · 0.80
getFileRevisionContentFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected