Neil K

40 Reputation

One Badge

5 years, 147 days

MaplePrimes Activity


These are replies submitted by

@acer 

This is exactly correct. For more clarity/functionality I have attached an updated version of the remove section tool that while still requiring an absolute path for the target file and needs to be run standalone, will open the new (.mw) document in the GUI if no destination file (.mw) is specified.
 

RemoveSection := module()
    local ModuleApply := proc(target, destination:=FAIL)
        if destination <> FAIL then
            XMLTools:-WriteFile(destination, subsindets(XMLTools:-ReadFile(target), ':-specfunc'(_XML_Section), section_handler));
        else
            Worksheet:-Display(XMLTools:-ToString(subsindets(XMLTools:-ReadFile(target), ':-specfunc'(_XML_Section), section_handler)));
        end if;
    end proc;
    
    local section_handler := proc(s)
        local partresult := remove(type,[op(s)],`=`);
        return op(subsindets(partresult, ':-specfunc'(_XML_Title), f -> `_XML_Presentation-Block`("",_XML_Group("view"="presentation","inline-output"="false",    
            "applyint"="true","applyrational"="true","applyexponent"="false","",_XML_Input(op(f))))));
    end proc;
end module:

#RemoveSection takes two arguments the first is the target file and the second is the destination file where the target file will be written without sections if no destination is specified the document without sections will be opened as a new maple document in the GUI.


 

Download RemoveSection.mw

Page 1 of 1