diff --git a/WsNovelParser/htmlprint.cpp b/WsNovelParser/htmlprint.cpp index 9fbfbd8..05b2467 100644 --- a/WsNovelParser/htmlprint.cpp +++ b/WsNovelParser/htmlprint.cpp @@ -711,11 +711,10 @@ void printer::AstGenerate::append_tokens(QDomElement _elm, std::shared_ptr s auto body = doc.createElement(u8"ast"); doc.appendChild(body); body.setAttribute(u8"time", QDateTime::currentDateTime().toString(u8"yyyyMMdd_hhmmss")); + body.setAttribute(u8"dir_src", src_root.absolutePath()); element_stack.append(body); }break; case NovelNode::Document: break; @@ -750,7 +750,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s dom_story.setAttribute(u8"name", story_node->name()); dom_story.setAttribute(u8"address", (qulonglong)story_node.get()); - dom_story.setAttribute(u8"file-path", story_node->filePath()); + dom_story.setAttribute(u8"file-path", src_root.relativeFilePath(story_node->filePath())); dom_story.setAttribute(u8"sort", story_node->sort()); append_tokens(dom_story, story_node); @@ -768,7 +768,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s dom_fragment.setAttribute(u8"name", fragment_node->name()); dom_fragment.setAttribute(u8"address", (qulonglong)fragment_node.get()); - dom_fragment.setAttribute(u8"file-path", fragment_node->filePath()); + dom_fragment.setAttribute(u8"file-path", src_root.relativeFilePath(fragment_node->filePath())); append_tokens(dom_fragment, fragment_node); }break; @@ -779,7 +779,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s current_text.appendChild(dom_text); dom_text.setAttribute(u8"text", text_node->content()); - dom_text.setAttribute(u8"file-path", text_node->filePath()); + dom_text.setAttribute(u8"file-path", src_root.relativeFilePath(text_node->filePath())); append_tokens(dom_text, text_node); }break; @@ -796,7 +796,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s dom_refer.setAttribute(u8"story", refer_node->storyRefer()); dom_refer.setAttribute(u8"fragment", refer_node->fragmentRefer()); - dom_refer.setAttribute(u8"file-path", refer_node->filePath()); + dom_refer.setAttribute(u8"file-path", src_root.relativeFilePath(refer_node->filePath())); append_tokens(dom_refer, refer_node); }break; @@ -813,7 +813,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s dom_volume.setAttribute(u8"name", volume_node->name()); dom_volume.setAttribute(u8"address", (qulonglong)volume_node.get()); - dom_volume.setAttribute(u8"file-path", volume_node->filePath()); + dom_volume.setAttribute(u8"file-path", src_root.relativeFilePath(volume_node->filePath())); append_tokens(dom_volume, volume_node); }break; @@ -830,7 +830,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s dom_article.setAttribute(u8"name", article_node->name()); dom_article.setAttribute(u8"address", (qulonglong)article_node.get()); - dom_article.setAttribute(u8"file-path", article_node->filePath()); + dom_article.setAttribute(u8"file-path", src_root.relativeFilePath(article_node->filePath())); append_tokens(dom_article, article_node); }break; @@ -841,7 +841,7 @@ bool printer::AstGenerate::visit(std::shared_ptr s ast_element.appendChild(dom_rank); dom_rank.setAttribute(u8"rank", rank_node->rankNumber()); - dom_rank.setAttribute(u8"doc-path", rank_node->filePath()); + dom_rank.setAttribute(u8"doc-path", src_root.relativeFilePath(rank_node->filePath())); append_tokens(dom_rank, rank_node); }break; diff --git a/WsNovelParser/htmlprint.h b/WsNovelParser/htmlprint.h index ef369fa..7b83a0f 100644 --- a/WsNovelParser/htmlprint.h +++ b/WsNovelParser/htmlprint.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include #include #include @@ -162,13 +163,14 @@ namespace printer { class AstGenerate : public lib_parse::TreeVisitor { private: + QDir src_root; QDomDocument doc; QList element_stack; void append_tokens(QDomElement _elm, std::shared_ptr inst); public: - AstGenerate(); + AstGenerate(const QDir &src_root); QString content() const; diff --git a/WsNovelParser/main.cpp b/WsNovelParser/main.cpp index e4b6ff4..7748c26 100644 --- a/WsNovelParser/main.cpp +++ b/WsNovelParser/main.cpp @@ -99,7 +99,7 @@ int main(int argc, char* argv[]) { else if (access_ptr) { QTime time_stamp = QTime::currentTime(); lib_parse::VisitorControl control; - auto visitor = std::make_shared(); + auto visitor = std::make_shared(source_dir); control.visitWith(access_ptr, visitor);; auto dom_result = visitor->content(); QFile file(destination_dir.absoluteFilePath(u8"storyline.xast"));