V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
anai1943
V2EX  ›  程序员

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

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

    大致需求

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

    • 多个试题组成试卷,试卷需要导出 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   ·   我们的愿景   ·   实用小工具   ·   2814 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 14:42 · PVG 22:42 · LAX 07:42 · JFK 10:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.