题库试卷导出 docx 系列问题,求交流 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
anai1943
V2EX    程序员

题库试卷导出 docx 系列问题,求交流

  •  
  •   anai1943 2018-07-24 15:36:33 +08:00 3276 次点击
    这是一个创建于 2645 天前的主题,其中的信息可能已经有所发展或是发生改变。

    大致需求

    • 富文本编辑器录入试题,支持公式录入

    • 多个试题组成试卷,试卷需要导出 docx 文件供线下打印使用

    解决方案

    • 试题录入:CKeditor + wiris,保存公式的 latex

    • 试题 web 页面显示,mathjax 处理 latex 公式正常显示

    • 导出 docx,目前采用 mathjaxnode 或 LaTeXML 将录入的 html 格式中的 latex 转换成 mathml,再用 pandoc 结合 reference.docx 导出 docx 文件

    未解决

    • pandoc 的 docx 样式参照文件 reference.docx 应该是不支持同一个类型的标签多个样式的,例如 html to docx 时,html 里面有多个 table,每个 table 给不同的样式,很难实现;

    • 一些特殊的 word 样式,比较难处理,例如中文的着重号 (emphasis mark);

    求助

    • 目前是否有成熟的 html to docx 的解决方案,测试过 phpword, phpdocx, python-docx, docx4j 等,还未找到合适的解决办法;
    第 1 条附言    2018-07-24 16:10:33 +08:00

    附 (题目录入的 html 片段)

    • 数学题,含 latex 公式
    <p>一、选择题(本大题共 12 小题,共 60 分)</p> <p>1、 集合\(A=\{x||x|\leqslant 2,x∈N^{*}\}\),\(B=\{y|y=x^{2},x∈R\}\),则\(A∩B=(\)  \()\)</p> <table> <tr> <td><p>A. \(\{x|x\geqslant 0\}\)</p></td> <td><p>B. \(\{x|x\geqslant 1\}\)</p></td> <td><p>C. \(\{1,2\}\)</p></td> <td><p>D. \(\{0,1,2\}\)</p></td> </tr> </table> 
    • 语文题,含着重号,html 结构采用背景图来处理显示
    下列各句中加点成语的运用,全部正确的一项是(  ) <br><bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">危</bdo> ①在奥运会和残奥会期间,面对恐怖分子的 <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">言</bdo> <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">危</bdo> <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">行</bdo>,巴西将调动 4.7 万名军人参与反恐、关键基础设施的安保、维持治安和接待外国元首。 <br>②家庭和学校要在教育的各个环节保护孩子的好奇心 
    5 条回复    2020-05-17 22:06:53 +08:00
    anai1943
        1
    anai1943  
    OP
       2018-07-24 15:47:16 +08:00
    ## 附 (题目录入的 html 片段)

    * 数学题,含 latex 公式

    ```
    <p>一、选择题(本大题共 12 小题,共 60 分)</p>
    <p>1、 集合\(A=\{x||x|\leqslant 2,x∈N^{*}\}\),\(B=\{y|y=x^{2},x∈R\}\),则\(A∩B=(\)  \()\)</p>
    <table>
    <tr>
    <td><p>A. \(\{x|x\geqslant 0\}\)</p></td>
    <td><p>B. \(\{x|x\geqslant 1\}\)</p></td>
    <td><p>C. \(\{1,2\}\)</p></td>
    <td><p>D. \(\{0,1,2\}\)</p></td>
    </tr>
    </table>
    ```

    * 语文题,含着重号,html 结构采用背景图来处理显示
    ```
    下列各句中加点成语的运用,全部正确的一项是(  )
    <br><bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">危</bdo>
    ①在奥运会和残奥会期间,面对恐怖分子的
    <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">言</bdo>
    <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">危</bdo>
    <bdo data-type="emphasis" style="background: url(./point.png) no-repeat center bottom;padding-bottom: 4px;">行</bdo>,巴西将调动 4.7 万名军人参与反恐、关键基础设施的安保、维持治安和接待外国元首。
    <br>②家庭和学校要在教育的各个环节保护孩子的好奇心
    ```
    panpanpan
        2
    panpanpan  
       2018-07-24 16:34:14 +08:00
    如果只是为了打印建议用 html to pdf,chrome 可以很好地帮你解决样式问题。
    liuzuo
        3
    liuzuo  
       2018-07-24 17:08:46 +08:00
    @panpanpan 赞同,打印时导出 pdf
    rankrank
        4
    rankrank  
       2019-03-29 17:14:50 +08:00
    楼主你好,我也遇到同样的问题,方便交流一下吗? email: master.yxp#gmail.com
    bylh
        5
    bylh  
       2020-05-17 22:06:53 +08:00
    我现在也是这一套,改特殊样式只能把 docx 解压改 xml, 然后再压缩回去,问下你现在有新的方案了吗,可否交流下
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3316 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 11:40 PVG 19:40 LAX 04:40 JFK 07:40
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86