【问题标题】:OneNote API (REST) -- How to maintain the line breaks and spacing of the OneNote page while updating the content of page using PATCH service?OneNote API (REST) -- 如何在使用 PATCH 服务更新页面内容的同时保持 OneNote 页面的换行和间距?
【发布时间】:2017-05-17 05:01:29
【问题描述】:

我正在使用 OneNote 的 GET pages REST API 获取 OneNote 页面的 HTML。这是虚拟代码 -

<html lang="nl-NL"> <head> 
<title>Sales meeting III</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="created" content="2017-03-14T17:30:00.0000000" /> 
</head> 
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt"> 
<div id="div:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{50}" style="position:absolute;left:48px;top:115px;width:625px"> 
<p id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{34}" style="font-size:17pt;margin-top:0pt;margin-bottom:0pt">Sales Meeting</p> 
<p id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{36}" style="font-size:10pt;color:gray;margin-top:0pt;margin-bottom:0pt">donderdag 9 maart 2017</p> 
<p id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{38}" style="font-size:10pt;color:gray;margin-top:0pt;margin-bottom:0pt">20:00</p> 
<p id="p:{d6174a59-03a8-4010-9ad9-e5a2e6f57bb3}{28}" lang="en-US" data-tag="to-do" data-id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{40}" style="margin-top:0pt;margin-bottom:0pt">Send draft press release to marketing team</p><br/><br/>  
<p id="p:{d6174a59-03a8-4010-9ad9-e5a2e6f57bb3}{33}" lang="en-US" data-tag="to-do" data-id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{43}" style="margin-top:0pt;margin-bottom:0pt">Schedule briefing</p><br/><br/> 
<p id="p:{d6174a59-03a8-4010-9ad9-e5a2e6f57bb3}{38}" lang="en-US" data-tag="to-do" data-id="p:{e5d84e97-3676-4df2-9bc6-b9583ebae493}{45}" style="margin-top:0pt;margin-bottom:0pt">Jack is the greatest</p> 
<p id="p:{b1177410-4d6e-4ef7-b82c-32695a02218b}{13}" lang="en-US" style="margin-top:0pt;margin-bottom:0pt"></p> <br/><br/>
<br/><br/>
<p id="p:{b1177410-4d6e-4ef7-b82c-32695a02218b}{13}" lang="en-US" style="margin-top:0pt;margin-bottom:0pt">This is Testing</p> <br/><br/>
</div> </body> </html> 

现在,我通过 PATCH API 中的“替换”方法使用其唯一 ID 仅更新“p”(段落)标签。据我所知,此操作与页面的其余 HTML 完全无关。内容正在正确更新,我从 API 获得了成功的响应,但它也在删除 br 标签。这会扰乱页面的缩进。

如何保持页面的缩进或如何避免删除页面的br标签或换行符,我希望它们在页面上保持原样。

提前致谢。

【问题讨论】:

    标签: onenote onenote-api


    【解决方案1】:

    嗨 Anupam
    您如何创建 OneNote 页面?
    我刚刚尝试通过编程方式和在 OneNote Online 中直接编辑来创建页面,并且 br 标记仅限于段落标记并且在修补后仍然有效。

    【讨论】:

    • 嗨 Codeye,我正在手动创建页面,然后使用页面 ID 我正在使用 REST API 的补丁方法以编程方式更新页面内容。我希望你能得到你的查询的答案。我仍在寻找上述问题的解决方案。感谢您的快速回复。
    【解决方案2】:

    以下是您 2 个问题的答案 -

    1. 如何维护换行符

      • 要保留换行符“br”,您可以替换整个“div”而不是页面中的特定项目
    2. 如何保持缩进

      • 目前OneNote Api不支持“pre”标签外的缩进。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多