Rebol / Red Parse html rules returns true but nothing is inserted

后端 未结 1 909
猫巷女王i
猫巷女王i 2021-01-28 14:56

I have a parse rules that returns true but it doesn\'t insert my text as expected : the html is unchanged whereas it should have inserted at the end of the main closing div. I t

1条回答
  •  自闭症患者
    2021-01-28 15:26

    Here a solution with probe to debug

    rules: [
         thru 
    (div-count: 1) some [ "" mark: ( probe -- div-count if div-count = 0 [insert mark "closing main div"]) skip | skip ] ] parse/all content rules

    The problems with your rules are, that the div-count is never or seldom subtracted. The parse pointer goes straight to the next opening div as to is always the first fulfilled condition.

    You can break out or better return from parse if you add a to end after a successful condition. If you are unsure use brackets for grouping [ sucessful sub-rules ... to end ]

    An example with an end-rule

    end-rule: [] ; or none
    rules: [
        thru 
    (div-count: 1) some [ [""mark: (-- div-count if div-count = 0 [insert mark "closing main div" end-rule: [to end]]) end-rule ] | skip ]

    ]

    0 讨论(0)
提交回复
热议问题