Rebo/Red parse: Is it possible to copy between two marks embedding nested div

此生再无相见时 提交于 2019-12-25 03:12:03

问题


Subsequent to Rebol/Red parse: how to copy between 2 marks let's now suppose I achieve to mark a string with some marks with a complex parse rule having nested div (whatever that rule), is there a general way to copy between mark1 and mark2, at least is there a specific way for this kind of nested div example:

    {
        <div>
        a ; <- mark1
            <div>
                b
            </div>
            <div>
            c
            </div>
        d ; <- mark2
        </div> 

        <div>
        e
            <div>
                f
            </div>
            <div>
            g
            </div>
        h
        </div>  
    }


    rule: [
        mark1:
        ...
        mark2:
        copy mark1 to mark2
    ]

回答1:


This is no problem with the already shown solutions, but if you want to make it a little bit more complicated you could go back to an already defined / marked point in your src as in this example.

src: {1234567890abcdefghijklmnopqrstuvxyz}
>> parse src [ skip mark: to "a" mark2:  :mark   to "3" mark1: to end]  
== true
>> mark1
== "34567890abcdefghijklmnopqrstuvxyz"

pay attention to :mark It set back the pointer to an prior defined point.

So the answer to your former question would look like that

rule: [
    to "b" mark1: thru "e" mark2: 
    :mark1 copy text to mark2
]

Here replace "b" and "e" according your your wished points, maybe "a" and "d".



来源:https://stackoverflow.com/questions/50088909/rebo-red-parse-is-it-possible-to-copy-between-two-marks-embedding-nested-div

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!