Doubao journal format

From ahang1598/doubao-workbuddy-qwenwork-skills · View interactive version

Doubao journal format is an AI agent skill from the GitHub repository ahang1598/doubao-workbuddy-qwenwork-skills. 用于对学术论文类 Word/DOCX 文档进行期刊、学校、会议或课程要求的格式排版与修复。当用户需要把论文原稿套用.docx 模板或明确格式规则、或提到论文排版、期刊投稿格式、学位论文格式、会议论文模板、时使用;如果同一请求同时包含论文 Word 排版和任何非排版任务,必须先停止并询问用户选择“只做格式排版”还是“作为复合任务拆分处理”,在用户明确选择前不得执行排版。不用于论文写作、润色、降重、翻译、代写、文献检索、补引用、验证引用、伪造数据/引用,或普通非论文 Word 文档套模板;

How to use this skill

Skill file

DOCX Journal Format

Apply an academic journal DOCX template to a target DOCX without reconstructing the document through python-docx. The tool edits the OpenXML package directly and keeps body text, formulas, images, OLE objects, tables, and relationships in place.

Trigger And Boundaries

Use this skill only when the user explicitly asks for paper formatting, journal formatting, Word formatting, document typesetting, applying a template format to a Word file, or reformatting a .docx according to another .docx or explicit formatting rules.

Before running any formatting tool, enforce these input boundaries in this exact order:

End the turn after asking. Continue only after the user explicitly chooses A or clearly says to ignore all non-formatting demands and do formatting only. If the user chooses B, do not use this skill to perform the non-formatting parts.

If a boundary check fails, stop before editing files and ask for the missing input in one concise message.

Composite hard-stop examples:

Response must only say that the request mixes DOCX formatting with polishing/plagiarism-reduction, then ask the user to choose A. 只做 DOCX 格式排版 or B. 作为复合任务先拆分非排版部分. Do not read or edit the document in that turn.

Response must only say that the request mixes DOCX formatting with literature/reference acquisition, then ask the same A/B choice. Do not browse or format in that turn.

Response must only say that translation/SCI rewriting is non-formatting work and ask the same A/B choice. Do not translate or format in that turn.

User-Facing Output

When formatting succeeds, return only the final .docx as the main deliverable. In the final response:

Detailed Modules

Keep this main file as the route map. Load the detailed module only when its surface is reached by the request or by the mandatory route:

Do not act from memory on a module surface. Read the corresponding reference file before applying that part of the workflow.

Mandatory Route

Use this order for every formatting run:

  1. Confirm the trigger and boundary checks above.

1a. Run the composite-request hard stop before every other action. If triggered, ask the A/B clarification question and stop the turn. Do not perform any other mandatory-route step in the same response.

  1. Read references/preservation-rules.md before editing or repacking anything.
  2. Detect non-.docx format-source inputs before extraction. This includes .pdf, images, website links, legacy .doc/.dot, and any other non-OpenXML source. Extract text rules first. Use visual/geometry tools only to detect reliable single-column/double-column fallback choice. For PDF column detection, treat left-edge clustering as insufficient by itself; require left/right body-band and gutter evidence, or cross-page stable column-start aggregation with low crossing ratio when sample pages are sparse. Mark the source as lower confidence, set non_docx_standard_fallback, and save the risk for the final notes.
  3. Detect whether the non-.docx source is a PDF sample issue, sample article, publisher proof, author instructions, submission guidelines, or PDF format instructions. Read references/template-distill-render-qa.md; run scripts/extract_pdf_format.py when practical. Use generated pdf_rules.json as --rules-json and pass --format-source-type text_rules or rely on _meta.source_type="text_rules". The PDF rules JSON must contain only explicit text style rules, explicit text-derived postprocess_operations, and _meta.fallback_columns/source_column_detection; it must not contain visual role/alignment/typography rules. Continue even when no explicit PDF text rule is extracted by applying the selected standard fallback and warning the user.
  4. Detect legacy .doc/.dot Word inputs before zip validation. Convert them to a temporary .docx only to extract text and reliable column-count metadata. Route the converted source as converted_docx_template/text-only evidence; do not use converted style XML, direct formatting, headers/footers, support files, or page XML as style authority. Do inspect converted sectPr/w:cols and source filename keywords only to choose single-column or double-column fallback; if detection fails, default to single-column and record the reason.
  5. Detect whether the request or Word evidence indicates single-column to multi-column, multi-column to single-column, or mixed-column migration. Warn about image/table/formula/caption/object/section risks before formatting and record the risk for final notes.
  6. Detect whether the format source is a website link. Extract available website/text evidence, and if image-based instructions appear inaccessible, record the risk and suggest screenshots in the final notes. For website links only, use double-column fallback only when the website text or user instruction explicitly says the submitted manuscript should be double-column; otherwise default to single-column and record website_unspecified_columns_default_single. Stop only if the website yields no usable formatting evidence.
  7. Validate both Word inputs are real .docx zip packages, unless the format source is explicit user text rules.
  8. Extract template and target packages.
  9. Read references/template-distill-render-qa.md, then run structural QA on the template and target-before documents when practical. Treat this as the evidence contract for section, style, direct-format, table geometry, image anchors, Word fields, heading hierarchy, object, and package-part preservation.
  10. Read references/style-routing.md, then read template body text for prose formatting rules before style injection.
  11. Lock the source-aware evidence priority before building styles. Native .docx/.dotx: user_rules > template_text_rules > representative_template_direct_format > template_style_xml > property-level granular fallback only when template_text_rules are explicit and core properties are missing/default. Do not apply whole-role fallback to clean native DOCX styles unless a table/equation-specific fallback is explicitly triggered. All non-.docx sources, including legacy .doc/.dot, PDF, image/OCR, website, screenshot, and externally supplied visual rules: user_rules > extracted_text_rules > source_column_detection_for_fallback_variant > bundled_OOXML_fallback > legacy_dictionary_fallback; for website links, the source-column step is allowed only when website/user text explicitly names the manuscript column count, otherwise it is website_unspecified_columns_default_single. Blank/carrier templates: user_rules > extracted_text_rules > bundled_OOXML_fallback materialized into docDefaults/Normal/role styles. The bundled fallback is assets/fallback_ooxml_spec.json, with four variants: Chinese single-column, Chinese double-column, English single-column, and English double-column. It stores role-level pPr_xml/rPr_xml, Normal, body baseline, table three-line tblPr/tcPr, equation paragraph baseline, section/column metadata, and Chinese bilingual caption policy. Old dictionary fallback is only an emergency missing-field backup after the OOXML fragment has been merged and must not override explicit native .docx text-rule channels. For every source type, re-apply explicit user/text rules after fallback merge so locked channels such as font, size, line spacing, indentation, numbering, or caption wording cannot be overwritten by fallback. Representative direct formatting remains allowed only for native DOCX style extraction; never promote first-run formatting as whole-role style. For non-.docx carriers, do not inherit Heading/Reference colors, underlines, borders, small caps, theme defaults, support files, headers/footers, or page XML unless explicit user/text rules require them; only allowed column evidence may affect fallback variant selection.

12a. Validate rules.json before style-spec construction. Record valid roles, invalid roles, normalized OOXML-summary fields, and ignored fields in qa_report.format_source.rules_schema_diagnostics. If a role has no recognized deterministic style keys after normalization, emit a clear schema warning instead of silently falling back. Normalize line-spacing aliases and decimals at this stage: line_spacing: "1.5", spacing.line: "1.5", double-spaced, and single-spaced must become legal Word w:line integers before they enter style_spec.json. A user rule that explicitly sets body line spacing must also update weak-source Normal and docDefaults body baselines so unbound/body-like paragraphs cannot revert to Word default w:line="240".

12b. After style installation and before repack, scan styles.xml, document.xml, headers/footers, footnotes/endnotes, and other Word XML parts for invalid spacing values. If any w:spacing/@w:line is decimal or textual, repair it to Word-compatible integer twips/line-multiple values and write the repair count into qa_report.format_source.spacing_value_normalization.

  1. Build an intermediate role style spec JSON from the template/evidence source only. The template evidence contract may feed style_spec.json; the target file must not. Store source type, original extension, conversion route, evidence priority, fallback language, fallback columns, fallback-column detection source, and low-confidence warnings in style_spec._meta/qa_report.format_source when available. When the format source is a blank/carrier package or weak external source, materialize the bundled OOXML fallback into style_spec before installation so title, heading1, body, equation, and other roles carry explicit fallback paragraph spacing/font/字号 rather than inheriting carrier defaults. Text/user rules merge at property level: for example, 正文宋体五号 locks CJK font and size while unspecified line spacing, Latin font, indentation, and alignment still come from the selected OOXML fallback variant.
  2. If page setup, headers/footers, sections, tables, formulas, OLE objects, or columns are involved, read references/equations-tables-sections.md before those steps.
  3. Before applying page setup, detect whether a mixed-column template or double-column fallback requires target section-structure repair. If the target has only one section and the template/fallback clearly has front/body sections with different column counts, insert a conservative continuous section break before the target body start. For weak/non-.docx/blank-carrier double-column fallback, front matter stays single-column and body starts double-column; never apply double columns to the whole single-section document when the body start is unclear.
  4. Apply page setup and headers/footers to every section, including paragraph-level pPr/sectPr.

16a. Clean inherited target header/footer background watermarks before template header/footer import. Remove image-only target header*.xml/footer*.xml paragraphs whose drawings are behind text or large anchored background images. Do not remove header/footer paragraphs containing visible text, page fields, tabs/breaks, body images, or normal template header/footer content imported afterward.

  1. Identify target paragraph roles without trusting target styles, and audit the role_map before style injection. Display equations/formulas must be mapped as the independent equation role before generic body. For template role-source extraction, run content-consistency checks before accepting any paragraph as the sample for title, author, body, or other core roles: publisher metadata, DOI/date/copyright/received/revised/accepted notes, footnotes, operation instructions, and placeholder/rule prose are not representative paper content even when they appear early, have large fonts, or use custom Word styles.
  2. Install styles from the intermediate spec and bind target roles to those styles only after the role-map preflight. For blank_carrier_template and other weak external style sources, also write the body fallback baseline into target docDefaults and Normal before binding so an unbound or body-like paragraph cannot display with the carrier's Word default single spacing.
  3. If numbering, bibliography, reference citations, heading auto-numbering, or superscripts are involved, read references/references-numbering-superscript.md before those steps.
  4. If any role style contains w:numPr/w:numId, copy the corresponding template numbering.xml num and abstractNum definitions into the target, allocate new non-conflicting IDs, and rewrite role style numId values to the new target IDs. reference_item is excluded only when the template uses visible text reference prefixes; it must be included when the template uses Word automatic bibliography numbering.
  5. During role-style installation, after reference_numbering_map.json is known, enforce reference-list indentation mode. In visible-text or non-automatic reference numbering, if reference_item has no explicit w:ind, create <w:ind w:left="420" w:hanging="420"/>; if it has hanging without a safe left, add/raise left. In Word automatic numbering mode, do not add style-level hanging indentation because numbering levels usually control it.

21a. For weak/non-DOCX text-rule sources with no reliable Word XML numbering evidence, use the standard reference-list numbering fallback [1], [2], ... only for paragraphs mapped as reference_item, unless explicit text rules specify another prefix style or disable numbering. Never add numbers to body citations, headings, formulas, captions, URLs, DOI-only continuation lines, or any paragraph outside reference_item; ask the user to confirm bibliography order in the final notes when numbers were added or renumbered.

  1. For heading roles, if a target heading already begins with a manual number but the generated heading style uses Word automatic numbering, use a no-number mirror of that same generated heading style for only that paragraph. Preserve template automatic numbering for plain headings without manual prefixes.
  2. Extract template equation tab-stop layout and equation-number tab layout into equation_layout_map.json only for internal audit or when requested.
  3. Extract template table body formatting into table_format_map.json only for internal audit or when requested. This is separate from table_caption.
  4. If the template has no usable table XML evidence, or only weak/placeholder table evidence, use the selected variant's bundled OOXML three-line table fallback for both Chinese and English templates. The fallback may only change borders and cell vertical alignment/margins from the sample XML: top rule, header bottom rule, bottom rule, no vertical/internal grid lines. Do not rely on table-level tblBorders alone; also write cell-level borders for first-row top, inferred final-header-row bottom, final-row bottom, and explicit none for left/right/internal borders. Multi-row headers must be inferred from merge topology, spanning group cells, short label/subheader rows, and the first data-like row; put the header-bottom rule below the final header row such as 准确度 over Top1/Top5, not blindly below row 1. When a composite header has more than one row, also write a thin horizontal separator between header levels. Preserve table width, row/column count, merge topology, cell text, formulas, drawings, and media, and report the fallback for final visual confirmation.
  5. Extract template reference-list numbering evidence into reference_numbering_map.json only for internal audit or when requested.
  6. Extract template run-level superscript markers and write superscript_map.json only for internal audit or when requested.
  7. Clean direct paragraph/run formatting unless the user explicitly disables it.
  8. Run format-conformance QA immediately after role binding/direct-format cleanup and before reference numbering, table body, equation tab, and superscript passes. Compare role_map.json to the final target paragraphs and style_spec.json to the installed role styles. If a paragraph is bound to the wrong role style, or direct paragraph/run formatting still overrides role font,字号,颜色,加粗、缩进、行距、对齐等确定性属性, repair it automatically and audit again. Do not merely report deterministic conformance errors. Only unresolved or evidence-uncertain items become user notes.
  9. Apply reference-list numbering repair after role binding, conformance repair, and cleanup, only to target paragraphs already mapped as reference_item.
  10. Apply table body formatting after conformance repair, never by rewriting cell text, formulas, drawings, or merge topology. If final section geometry has multi-column body sections, constrain oversized inline/floating drawings and wide tables in those sections to the active column text width unless the object is clearly a small icon/logo. Preserve aspect ratio, cell text, formulas, media, and table topology; report scaled objects as visual-confirmation risks.
  11. Apply equation tab-stop layout after conformance repair, never by rewriting OMML formula content. If the template lacks numbered-equation tab-stop evidence, use the computed equation fallback for both Chinese and English templates: compute center and right tab stops from the equation paragraph's active section/column width, not the full page width. In two-column sections, the right tab must be the column right edge.
  12. Apply run-level superscript markers after conformance repair, never as whole-paragraph styles.
  13. For abstract/keyword paragraphs, keep the role style content non-bold and apply run-level bold only to the leading labels 摘要, 关键词, Abstract, and Key words/Keywords; the following abstract/keyword content must remain non-bold. In weak-source fallback, abstract and keyword content defaults to five-point size (w:sz=21).

34a. Abstract/keyword label recognition must include bracketed and colonless variants: [Abstract], 【Abstract】, ABSTRACT, [摘要], [Keywords], and KEY WORDS. These labels should map to abstract/keyword roles before heading/title/body heuristics, and the label run must be bold while following content is explicitly non-bold.

  1. After role-map-dependent passes, normalize explicit Chinese classification metadata containing 中图分类号 and 文献标志码 to one line using a right-aligned tab stop computed from page margins/body text width. Run this for native DOCX and weak-source routes because native templates may also use manual spaces for this row. Preserve any section break by moving paragraph-level sectPr from a merged following paragraph to the kept metadata paragraph.
  2. If and only if the user or extracted source prose clearly requested content/structure postprocess edits, read references/explicit-postprocess.md. For source prose rules, let scripts/extract_pdf_format.py or the text-rule classifier write postprocess_operations/_meta.postprocess_operations in rules.json; format_docx.py must auto-generate and run the temporary postprocess config. For reviewed/manual overrides, pass --explicit-postprocess-json. Supported examples include moving table/figure blocks after references, changing body citation markers such as [1] to italic (1), converting reference-list prefixes such as [1] to (1)/1/1., and normalizing Fig. N:/Table N: caption prefixes with optional first-sentence bold. Skip this option when the request is only style formatting or only visual examples. Figure relocation must never infer a figure from drawing/pict alone because MathType/OLE equations and inline body anchors can also contain preview images.

36a. postprocess_operations must normally be an array of explicit operation objects. If a legacy shorthand object is encountered, normalize it to explicit operations, emit a warning, and include the warning in qa_report.explicit_postprocess. Never silently skip malformed postprocess config. After execution, print a concise Postprocess results summary listing operation names, scopes, and changed/moved/added/skipped counts so the main run reveals what happened without requiring users to inspect JSON.

  1. Protect high inline content from fixed line-height clipping: paragraphs containing inline drawings, pictures, OLE/MathType objects, or OMML formulas must not keep effective lineRule=exact; override only those paragraphs to lineRule=auto before the first valid repack.
  2. Audit section count and verify every sectPr has the template page setup and template header/footer references.
  3. Audit role styles for internal conflicts between style/rPr and style/pPr/rPr.
  4. Audit numbering: every role style numId must exist in target numbering.xml.
  5. Repack and verify the output is a valid .docx.
  6. If explicit postprocess is enabled, run it after this first valid repack and before final structural/render QA. Record qa_report.explicit_postprocess and treat skipped complex objects or moved content as user-confirmation items. The postprocess report must include preservation checks for paragraph/table/drawing/OLE/OMML counts and paragraph-text multiset for move-only operations; any preservation issue must be surfaced as a final confirmation risk rather than hidden in JSON.
  7. Run final structural QA with qa_report.json when practical, including format-conformance repair stats, explicit postprocess stats, table geometry, three-line table border integrity, image anchors, high-inline-content fixed-line-spacing risk, header/footer background image watermarks, Word fields, heading hierarchy, object counts, and remaining direct formatting. Table QA must flag missing first-row top rule, missing final inferred-header-row bottom rule, missing multi-row header separators, and missing final-row bottom rule. Image/object QA must flag paragraphs where drawings/OLE/OMML still inherit lineRule=exact, because those paragraphs can visually clip images or formulas. Convert unresolved QA findings into final visual-confirmation notes instead of verbose applied-format lists.
  8. Run LibreOffice compatibility QA on the final DOCX before delivery: use LibreOffice/soffice only to load the final DOCX and export a temporary PDF. Before repack and QA, ensure every package relationship part (*.rels) serializes as default package relationship namespace <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">, never as ns0:Relationships. Record success/failure in qa_report.json. Do not save, normalize, or replace the final DOCX through LibreOffice because that can change formulas, OLE, anchors, fields, and Word-specific layout.
  9. Run target-before/final render comparison QA before delivery except when the target formatting source is text-only/OCR/non-DOCX-derived rules. Text-only sources include explicit plain-text rules, selectable PDF text rules, legacy .doc/.dot converted text rules, OCR text extracted from screenshots/images, and website/image text instructions. For these, visual comparison against the original target is misleading because the expected output may intentionally differ greatly. Pass --format-source-type text_rules/ocr_text_rules or put _meta.source_type="text_rules"/ocr_text_rules in rules.json, skip only target-before/final render comparison, record render_compare_skipped_text_rules, and still run structural QA plus LibreOffice compatibility QA. For native DOCX templates, render comparison remains mandatory. Render-engine priority is locked: Microsoft Word PDF export first, then LibreOffice PDF export, then any available system preview/QuickLook route, and Word GUI screenshot only as the last manual fallback. Automated comparison must use the same engine for both the original target and final DOCX; if one side fails under an engine, abandon that engine and try the next one for both files. Record the selected engine, attempted engines, page count, page dimensions, missing pages, and changed pages in qa_report.json. If all engines fail, record mandatory_render_compare_failed/render-QA risk and include it in the final user note. Do not silently skip this gate for native DOCX visual template sources.
  10. Do not expose PNGs or QA JSON by default.
  11. Return the .docx file to the user with the output notes described above, including unresolved format-conformance issues, explicit postprocess confirmation items, LibreOffice compatibility failure, render-QA failure, or skipped visual-QA risk when relevant.

Do not default to style-name matching. Target files often use style names that do not match the template.

Command

python3 scripts/format_docx.py \
  --template template.docx \
  --target paper.docx \
  --output output.docx

Useful options:

| Option | Meaning |

|---|---|

| --style-mode role | Default. Classify target content and bind it to generated template role styles. |

| --style-mode name | Legacy route. Match styles by w:name; use only when target/template style names are known to match. |

| --keep-direct-formatting | Disable direct-format cleanup. Warn that Word may still show old font/size. |

| --rules-json rules.json | User explicit formatting rules. These override template prose rules and template XML. |

| --style-spec-out style_spec.json | Write the intermediate role style spec for audit/reuse. |

| --style-spec-in style_spec.json | Reuse a reviewed intermediate role style spec. |

| --role-map-out role_map.json | Write target paragraph-to-role mapping for audit. |

| --role-map-in role_map.json | Reuse a reviewed target paragraph-to-role mapping as locked input. |

| --superscript-map-out superscript_map.json | Write template-derived run-level superscript marker rules for audit. |

| --superscript-map-in superscript_map.json | Reuse a reviewed run-level superscript marker map. |

| --equation-layout-map-out equation_layout_map.json | Write template-derived equation tab-stop layout map for audit. |

| --equation-layout-map-in equation_layout_map.json | Reuse a reviewed equation tab-stop layout map. |

| --table-format-map-out table_format_map.json | Write template-derived table body formatting map for audit. |

| --table-format-map-in table_format_map.json | Reuse a reviewed table body formatting map. |

| --allow-table-width-override | Allow template tblW/tblLayout to override target table width. Default preserves target widths when template width is auto/unspecified. |

| --allow-legacy-word-conversion | Compatibility flag. Legacy .doc/.dot inputs are automatically converted to temporary .docx when possible; the converted evidence is lower confidence and must be mentioned in final notes. |

| --reference-numbering-map-out reference_numbering_map.json | Write template-derived reference-list numbering repair map for audit. |

| --reference-numbering-map-in reference_numbering_map.json | Reuse a reviewed reference-list numbering repair map. |

| --format-report-out format_report.json | Write internal fallback/risk report for final user notes. Do not expose by default. |

| --qa-report-out qa_report.json | Write structural QA for template, target-before, and final DOCX. Do not expose by default. |

| --render-qa-dir render_qa/ | Optional directory for mandatory target-before/final render comparison QA. If omitted, the formatter creates <output-stem>_render_qa. Do not expose rendered PNGs by default. |

| --explicit-postprocess-json postprocess_ops.json | Optional, default off. Run explicit post-format content/structure operations only when the user clearly requests them. |

| --explicit-postprocess-report-out postprocess_report.json | Write internal explicit-postprocess report JSON. Do not expose by default. |

| --format-source-type ocr_text_rules | Mark the format source as text/OCR/image/website text rules. This skips misleading target-before/final visual comparison while keeping structural QA and LibreOffice compatibility QA. Non-DOCX sources should use text-rule routing plus fallback completion. |

| --format-source-type converted_docx_template | Mark a legacy .doc/.dot source converted to temporary .docx for text extraction only. The converted package is a carrier, not style authority; missing properties are completed by the standard fallback and final notes must recommend either a native DOCX/DOTX source or explicit text formatting instructions. |

| scripts/extract_pdf_format.py source.pdf --out-json pdf_evidence.json --rules-json pdf_rules.json | Extract selectable-text PDF format-guide rules, explicit text-derived structure operations, and optional single/double-column metadata. The generated rules JSON uses _meta.source_type="text_rules" and may include postprocess_operations; visual PDF data is retained only in full evidence for audit and must not define style properties or structure operations. |

| --body-cols N, --body-columns N | Preferred body column count for mixed-section templates or PDF/non-DOCX fallback when automatic column detection is ambiguous or wrong. |

| --no-style | Skip style import, role binding, and direct-format cleanup. |

| --no-page, --no-header, --no-support | Skip page setup, header/footer copy, or settings/font/theme copy. |

Version

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.