pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)
Res facta quae tamen fingi potuit ([personal profile] pauamma) wrote in [site community profile] dw_dev2017-11-16 11:35 pm
Entry tags:

Question thread #58

It's time for another question thread!

The rules:

- You may ask any dev-related question you have in a comment. (It doesn't even need to be about Dreamwidth, although if it involves a language/library/framework/database Dreamwidth doesn't use, you will probably get answers pointing that out and suggesting a better place to ask.)
- You may also answer any question, using the guidelines given in To Answer, Or Not To Answer and in this comment thread.
bytebuster: (StarTrek-Spock1-Approach)

[personal profile] bytebuster 2017-11-17 04:20 am (UTC)(link)
Is there a way to retrieve cut-tag end-markers in an HTML-rendered post?

Background. I'm writing a small browser script to enable the "Repost" functionality, similar to what the LJ has.
Since this uses no LJ API, I'm solely relying on rendered HTML pages for DW posts.

Problem. I'm having trouble detecting cut-tag markers, when my script is run on the post page (it works fine in journal entries page). Here's the difference:

In Journal entries page it looks like:
<div class="entry-content">
  <!-- (pre-cut body) -->
  <span class="cuttag_container">
    <!-- (expand button) -->
    <div style="display: none;" id="div-cuttag_bytebuster_9782148_1" aria-live="assertive">
      <!-- (here goes the cut body if expanded) -->
    </div>
  </span>
  <!-- (post-cut body) -->
</div>
On a page for specific entry:
<div class="entry-content">
  <!-- (pre-cut body) -->
  <a name="cutid1">
  <!-- (here goes the cut body) -->
  <!-- (post-cut body) -->
</div>
Most obviously, in 2nd case I can't determine where the cut ends.

Question. Is there any way to work this around? What if the DW engine were placed some named anchor element at the cut end?
Edited 2017-11-17 04:24 (UTC)
momijizukamori: Grey tabby cat with paws on keyboard and mouse. The text reads 'code cat is on the job', lolcats-style (CODE CAT)

[personal profile] momijizukamori 2017-11-18 05:12 am (UTC)(link)
I don't think it'd be a huge change - it'd probably take more time just to track down where that bit is generated from.

Which I may end up doing anyway because this thread made me go 'oh, posts pulled via the API should probably also contain information about where cut start and end too'