@ -37,39 +37,45 @@ bool Buffer::open(const string & new_file_name)
line . replace ( char_loc , 4 , " \n " ) ;
// Find link tags and process them.
for ( auto tag_loc = line . find ( " <a " ) ; tag_loc ! = - 1 ; tag_loc = line . find ( " <a " , tag_loc + 1 ) )
for ( auto tag_loc = line . find ( " <a " ) ; tag_loc ! = - 1 ; tag_loc = line . find ( " <a " , tag_loc + 1 ) )
{
+ + curr_link ;
auto tag_len = line . find_first_of ( ' > ' , tag_loc ) - tag_loc ;
std : : string link_tag = line . substr ( tag_loc , tag_len ) ;
std : : string link_tag = line . substr ( tag_loc + 3 , tag_len - 3 ) ;
auto second_space_loc = link_tag . find_first_of ( ' ' , 4 ) ;
std : : string file_name = link_tag . substr ( 4 , second_space_loc - 1 ) ;
std : : string link_name = link_tag . substr ( second_space_loc , tag_len - 1 ) ;
auto second_space_loc = link_tag . find_first_of ( ' ' , 0 ) ;
std : : string file_name = link_tag . substr ( 0 , second_space_loc - 1 ) ;
std : : string link_name = link_tag . substr ( second_space_loc + 1 ) ;
v_links_ . push_back ( { file_name , link_name } ) ;
line . replace ( tag_loc , tag_len , " < " + link_name + " >[ " + to_string ( curr_link ) + " ] " ) ;
line . replace ( tag_loc , tag_len + 1 , " < " + link_name + " >[ " + to_string ( curr_link ) + " ] " ) ;
}
// See if there is a new paragraph being made and make one if it is.
auto p_tag = line . find ( " <p> " ) ;
std : : string extra_text ;
if ( p_tag ! = - 1 )
// Search for all paragraphs in the line and add them to the v_lines vector.
for ( auto p_tag = line . find ( " <p> " ) ; p_tag ! = - 1 ; p_tag = line . find ( " <p> " ) )
{
extra_text = line . substr ( p_tag + 4 ) ;
std : : string extra_text = line . substr ( p_tag + 4 ) ;
line . erase ( p_tag ) ;
curr_p + = line ;
v_lines_ . push_back ( curr_p ) ;
curr_p = extra_text ;
}
else // Otherwise just append the data on this line to the current paragraph being read.
{
curr_p + = line ;
// However, if the paragraph is empty, then it shouldn't be added.
if ( curr_p ! = " " )
{
v_lines_ . push_back ( curr_p ) ;
curr_p = " " ;
}
line = extra_text ;
}
}
// Append any data left on this line to the current paragraph being read.
curr_p + = line ;
}
// Push the contents of curr_p as it has the last paragraph in the file.
v_lines_ . push_back ( curr_p ) ;
file_name_ = new_file_name ;
ix_top_line_ = 0 ;